Skip to content

Commit 740888d

Browse files
authored
Merge pull request #60 from GeneralsOnlineDevelopmentTeam/seer/fix-listbox-access-violation
GUI: Add safety checks to prevent access violations in getListboxBottomEntry
2 parents 617baae + 50625a1 commit 740888d

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ static Int getListboxBottomEntry( ListboxData *list )
197197
{
198198
Int entry;
199199

200+
// Safety checks to prevent access violations during screen transitions
201+
if( list == NULL )
202+
return 0;
203+
if( list->listData == NULL )
204+
return 0;
205+
if( list->endPos <= 0 )
206+
return 0;
207+
200208
// determine which entry is at the top of the display area
201209
for( entry=list->endPos - 1; ; entry-- )
202210
{

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ static Int getListboxBottomEntry( ListboxData *list )
197197
{
198198
Int entry;
199199

200+
// Safety checks to prevent access violations during screen transitions
201+
if( list == NULL )
202+
return 0;
203+
if( list->listData == NULL )
204+
return 0;
205+
if( list->endPos <= 0 )
206+
return 0;
207+
200208
// determine which entry is at the top of the display area
201209
for( entry=list->endPos - 1; ; entry-- )
202210
{

0 commit comments

Comments
 (0)