Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ static void adjustDisplay( GameWindow *window, Int adjustment,
GameWindow *child;

sData = (SliderData *)list->slider->winGetUserData();

// Safety check: ensure slider data is valid before accessing it
if( sData == NULL )
return;

list->slider->winGetSize( &sliderSize.x, &sliderSize.y );
// Take into account that there is a line-drawn outline surrounding listbox
sData->maxVal = list->totalHeight - ( list->displayHeight - TOTAL_OUTLINE_HEIGHT ) + 1;
Expand Down Expand Up @@ -1973,6 +1978,11 @@ WindowMsgHandledType GadgetListBoxSystem( GameWindow *window, UnsignedInt msg,
if( list->multiSelect )
delete[]( list->selections );

// Clear child window pointers to prevent dangling pointer access
list->slider = NULL;
list->upButton = NULL;
list->downButton = NULL;

delete (ListboxData *)window->winGetUserData();
window->winSetUserData( NULL );
list = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ static void adjustDisplay( GameWindow *window, Int adjustment,
GameWindow *child;

sData = (SliderData *)list->slider->winGetUserData();

// Safety check: ensure slider data is valid before accessing it
if( sData == NULL )
return;

list->slider->winGetSize( &sliderSize.x, &sliderSize.y );
// Take into account that there is a line-drawn outline surrounding listbox
sData->maxVal = list->totalHeight - ( list->displayHeight - TOTAL_OUTLINE_HEIGHT ) + 1;
Expand Down Expand Up @@ -1973,6 +1978,11 @@ WindowMsgHandledType GadgetListBoxSystem( GameWindow *window, UnsignedInt msg,
if( list->multiSelect )
delete[]( list->selections );

// Clear child window pointers to prevent dangling pointer access
list->slider = NULL;
list->upButton = NULL;
list->downButton = NULL;

delete (ListboxData *)window->winGetUserData();
window->winSetUserData( NULL );
list = NULL;
Expand Down
Loading