mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Fix #4944: Game crashes upon selecting objects in scenario editor
When the filter caused no results to be shown in the list, it would try to realloc for 0 bytes which returns NULL. The error shown in the console was a minor bug, the more serious issue was the the original memory was freed but the list pointer not updated. Instead just check for 0 items, dispose the list and return.
This commit is contained in:
parent
ae615e5d57
commit
4090522901
1 changed files with 7 additions and 0 deletions
|
@ -390,6 +390,13 @@ static void visible_list_refresh(rct_window *w)
|
|||
}
|
||||
}
|
||||
|
||||
if (_numListItems == 0)
|
||||
{
|
||||
visible_list_dispose();
|
||||
window_invalidate(w);
|
||||
return;
|
||||
}
|
||||
|
||||
void *new_memory = realloc(_listItems, _numListItems * sizeof(list_item));
|
||||
if (new_memory == NULL) {
|
||||
log_error("Unable to reallocate list items");
|
||||
|
|
Loading…
Reference in a new issue