diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp index a2b8bc5f3f7..0c70b52f472 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp @@ -197,6 +197,14 @@ static Int getListboxBottomEntry( ListboxData *list ) { Int entry; + // Safety checks to prevent access violations during screen transitions + if( list == NULL ) + return 0; + if( list->listData == NULL ) + return 0; + if( list->endPos <= 0 ) + return 0; + // determine which entry is at the top of the display area for( entry=list->endPos - 1; ; entry-- ) { diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp index d906b74d8b9..822f2bbe470 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp @@ -197,6 +197,14 @@ static Int getListboxBottomEntry( ListboxData *list ) { Int entry; + // Safety checks to prevent access violations during screen transitions + if( list == NULL ) + return 0; + if( list->listData == NULL ) + return 0; + if( list->endPos <= 0 ) + return 0; + // determine which entry is at the top of the display area for( entry=list->endPos - 1; ; entry-- ) {