Skip to content

[GEN][ZH] Prevent buffer overrun while writing to 'new_types', 'new_lensflares' in DazzleRenderObjClass #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ void DazzleRenderObjClass::Init_Type(const DazzleInitClass& i)
unsigned new_count=i.type+1;
DazzleTypeClass** new_types=W3DNEWARRAY DazzleTypeClass*[new_count];
unsigned a=0;
for (;a<type_count;++a) {
unsigned copy_count = min(type_count, new_count);
for (;a<copy_count;++a) {
new_types[a]=types[a];
}
for (;a<new_count;++a) {
Expand All @@ -693,7 +694,8 @@ void DazzleRenderObjClass::Init_Lensflare(const LensflareInitClass& i)
unsigned new_count=i.type+1;
LensflareTypeClass** new_lensflares=W3DNEWARRAY LensflareTypeClass*[new_count];
unsigned a=0;
for (;a<lensflare_count;++a) {
unsigned copy_count = min(lensflare_count, new_count);
for (;a<copy_count;++a) {
new_lensflares[a]=lensflares[a];
}
for (;a<new_count;++a) {
Expand Down
6 changes: 4 additions & 2 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@ void DazzleRenderObjClass::Init_Type(const DazzleInitClass& i)
unsigned new_count=i.type+1;
DazzleTypeClass** new_types=W3DNEWARRAY DazzleTypeClass*[new_count];
unsigned a=0;
for (;a<type_count;++a) {
unsigned copy_count = min(type_count, new_count);
for (;a<copy_count;++a) {
new_types[a]=types[a];
}
for (;a<new_count;++a) {
Expand All @@ -709,7 +710,8 @@ void DazzleRenderObjClass::Init_Lensflare(const LensflareInitClass& i)
unsigned new_count=i.type+1;
LensflareTypeClass** new_lensflares=W3DNEWARRAY LensflareTypeClass*[new_count];
unsigned a=0;
for (;a<lensflare_count;++a) {
unsigned copy_count = min(lensflare_count, new_count);
for (;a<copy_count;++a) {
new_lensflares[a]=lensflares[a];
}
for (;a<new_count;++a) {
Expand Down
Loading