From 0274b69396e94310e2c8b0c0d8d01c26ff74b2db Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Fri, 2 May 2025 17:22:34 +0200 Subject: [PATCH 01/10] Fix overflow (GEN) --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 6cae5235c5..176392529f 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -600,9 +600,10 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, if(newColumns > 1) { - char *percentages = new char[60]; + const Int size = 60; + char *percentages = new char[size]; char *token; - GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,200); + GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,size); if(strlen(percentages) == 0) { MessageBox(NULL,"You have specified a column amount greater then 1, please enter the same about of percentages","whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); From 04327afc55db9f12df8dc4dc579215d798eda7a5 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Fri, 2 May 2025 17:23:35 +0200 Subject: [PATCH 02/10] Fix overflow (ZH) --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index f4b7cf7521..671bb33199 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -600,9 +600,10 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, if(newColumns > 1) { - char *percentages = new char[60]; + const Int size = 60; + char *percentages = new char[size]; char *token; - GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,200); + GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,size); if(strlen(percentages) == 0) { MessageBox(NULL,"You have specified a column amount greater then 1, please enter the same about of percentages","whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); From 0dda338984f8d5d12f9202ef84fd9e144d2d54c6 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sat, 3 May 2025 21:53:27 +0200 Subject: [PATCH 03/10] Fixed memory leaks. --- .../Dialog Procedures/ListboxProperties.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 176392529f..0bd75b5af9 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -600,10 +600,8 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, if(newColumns > 1) { - const Int size = 60; - char *percentages = new char[size]; - char *token; - GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,size); + Char percentages[100]; + GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,sizeof(percentages)); if(strlen(percentages) == 0) { MessageBox(NULL,"You have specified a column amount greater then 1, please enter the same about of percentages","whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); @@ -613,7 +611,7 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, Int *newPercentages = new Int[newColumns]; Int i = 0; Int total = 0; - token = strtok( percentages, "," ); + Char *token = strtok( percentages, "," ); while( token != NULL ) { newPercentages[i] = atoi(token); @@ -622,23 +620,26 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, i++; if(i > newColumns && token) { - Char *whoopsMsg = new char[250]; + Char whoopsMsg[250]; sprintf(whoopsMsg,"You have Specified %d columns but I have read in more then that for the percentages, please double check your data", newColumns); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); + delete[] newPercentages; return 0; } else if( i < newColumns && !token ) { - Char *whoopsMsg = new char[250]; + Char whoopsMsg[250]; sprintf(whoopsMsg,"You have Specified %d columns but I have read in only %d for the percentages, please double check your data", newColumns, i ); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); + delete[] newPercentages; return 0; } else if((total > 100 ) || (total < 100 && !token )) { - Char *whoopsMsg = new char[250]; + Char whoopsMsg[250]; sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100.", newColumns, i - 1); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); + delete[] newPercentages; return 0; } } @@ -942,8 +943,8 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) SetDlgItemInt( dialog, EDIT_NUM_COLUMNS, listData->columns, FALSE ); if(listData->columns > 1) { - char *percentages = new char[60]; - char *tempStr = new char[60]; + Char percentages[100]; + Char tempStr[100]; sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { From 2b281db5e72e5f06072264aed40f004ff14fb874 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sat, 3 May 2025 21:56:43 +0200 Subject: [PATCH 04/10] Fixed memory leaks. --- .../Dialog Procedures/ListboxProperties.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 671bb33199..6317a01d0f 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -600,10 +600,8 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, if(newColumns > 1) { - const Int size = 60; - char *percentages = new char[size]; - char *token; - GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,size); + Char percentages[100]; + GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,sizeof(percentages)); if(strlen(percentages) == 0) { MessageBox(NULL,"You have specified a column amount greater then 1, please enter the same about of percentages","whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); @@ -613,7 +611,7 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, Int *newPercentages = new Int[newColumns]; Int i = 0; Int total = 0; - token = strtok( percentages, "," ); + Char *token = strtok( percentages, "," ); while( token != NULL ) { newPercentages[i] = atoi(token); @@ -622,23 +620,26 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, i++; if(i > newColumns && token) { - Char *whoopsMsg = new char[250]; + Char whoopsMsg[250]; sprintf(whoopsMsg,"You have Specified %d columns but I have read in more then that for the percentages, please double check your data", newColumns); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); + delete[] newPercentages; return 0; } else if( i < newColumns && !token ) { - Char *whoopsMsg = new char[250]; + Char whoopsMsg[250]; sprintf(whoopsMsg,"You have Specified %d columns but I have read in only %d for the percentages, please double check your data", newColumns, i ); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); + delete[] newPercentages; return 0; } else if((total > 100 ) || (total < 100 && !token )) { - Char *whoopsMsg = new char[250]; + Char whoopsMsg[250]; sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100.", newColumns, i - 1); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); + delete[] newPercentages; return 0; } } @@ -942,8 +943,8 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) SetDlgItemInt( dialog, EDIT_NUM_COLUMNS, listData->columns, FALSE ); if(listData->columns > 1) { - char *percentages = new char[60]; - char *tempStr = new char[60]; + Char percentages[100]; + Char tempStr[100]; sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { From 9631515c43d8ece2b6d266a37e792f76b8f6d788 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Mon, 5 May 2025 19:05:10 +0200 Subject: [PATCH 05/10] Correct code from incorrectly resolved merge conflict (GEN) --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 0bd75b5af9..ae6a73ffd0 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -637,7 +637,7 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, else if((total > 100 ) || (total < 100 && !token )) { Char whoopsMsg[250]; - sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100.", newColumns, i - 1); + sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100."); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); delete[] newPercentages; return 0; From 07199814967a3448c8f56da9d6f8efd40876a2b9 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Mon, 5 May 2025 19:06:07 +0200 Subject: [PATCH 06/10] Correct code from incorrectly resolved merge conflict (ZH) --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 6317a01d0f..384ad2d259 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -637,7 +637,7 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, else if((total > 100 ) || (total < 100 && !token )) { Char whoopsMsg[250]; - sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100.", newColumns, i - 1); + sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100."); MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL); delete[] newPercentages; return 0; From 783d6d8fffd7d0f0c921ae02804f096130a4e44c Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 8 May 2025 14:53:18 +0200 Subject: [PATCH 07/10] Increased percentages buffer size --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 384ad2d259..8201721216 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -600,7 +600,7 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, if(newColumns > 1) { - Char percentages[100]; + Char percentages[200]; GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,sizeof(percentages)); if(strlen(percentages) == 0) { @@ -943,8 +943,8 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) SetDlgItemInt( dialog, EDIT_NUM_COLUMNS, listData->columns, FALSE ); if(listData->columns > 1) { - Char percentages[100]; - Char tempStr[100]; + Char percentages[200]; + Char tempStr[200]; sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { From 4e11e48701da2f8aded54dfd0165d3a9da180b0f Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 8 May 2025 14:54:07 +0200 Subject: [PATCH 08/10] Increased percentages buffer size --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index ae6a73ffd0..97eddb4dd2 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -600,7 +600,7 @@ static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog, if(newColumns > 1) { - Char percentages[100]; + Char percentages[200]; GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,sizeof(percentages)); if(strlen(percentages) == 0) { @@ -943,8 +943,8 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) SetDlgItemInt( dialog, EDIT_NUM_COLUMNS, listData->columns, FALSE ); if(listData->columns > 1) { - Char percentages[100]; - Char tempStr[100]; + Char percentages[200]; + Char tempStr[200]; sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { From a1c3f178cf48499f2902f37bf825beba70d89727 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 8 May 2025 17:34:10 +0200 Subject: [PATCH 09/10] Updated buffer size to reflect required size (32 + 1) for iota --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 8201721216..8230c16bb1 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -944,7 +944,7 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) if(listData->columns > 1) { Char percentages[200]; - Char tempStr[200]; + Char tempStr[33]; sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { From 35d614a1a7a2c64ee9906be166518fc748e2414a Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Thu, 8 May 2025 17:34:32 +0200 Subject: [PATCH 10/10] Updated buffer size to reflect required size (32 + 1) for iota --- .../GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 97eddb4dd2..d6d9e25ec0 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -944,7 +944,7 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) if(listData->columns > 1) { Char percentages[200]; - Char tempStr[200]; + Char tempStr[33]; sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) {