Skip to content

Commit c27f3dc

Browse files
xezonOmniBlade
authored andcommitted
[GEN][ZH] Fix heap-buffer-overflow in getListboxBottomEntry (#462)
1 parent d4dedf9 commit c27f3dc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,17 @@ static Int getListboxBottomEntry( ListboxData *list )
202202
{
203203
Int entry;
204204

205-
// determin which entry is at the top of the display area
205+
// determine which entry is at the top of the display area
206206
for( entry=list->endPos - 1; ; entry-- )
207207
{
208+
if( entry < 0 )
209+
return 0;
208210
if( list->listData[entry].listHeight == list->displayPos + list->displayHeight )
209211
return entry;
210212
if( list->listData[entry].listHeight < list->displayPos + list->displayHeight && entry != list->endPos - 1)
211213
return entry + 1;
212214
if( list->listData[entry].listHeight < list->displayPos + list->displayHeight)
213215
return entry;
214-
if( entry < 0 )
215-
return 0;
216216
}
217217

218218
return 0;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,17 @@ static Int getListboxBottomEntry( ListboxData *list )
202202
{
203203
Int entry;
204204

205-
// determin which entry is at the top of the display area
205+
// determine which entry is at the top of the display area
206206
for( entry=list->endPos - 1; ; entry-- )
207207
{
208+
if( entry < 0 )
209+
return 0;
208210
if( list->listData[entry].listHeight == list->displayPos + list->displayHeight )
209211
return entry;
210212
if( list->listData[entry].listHeight < list->displayPos + list->displayHeight && entry != list->endPos - 1)
211213
return entry + 1;
212214
if( list->listData[entry].listHeight < list->displayPos + list->displayHeight)
213215
return entry;
214-
if( entry < 0 )
215-
return 0;
216216
}
217217

218218
return 0;

0 commit comments

Comments
 (0)