1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 03:23:15 +01: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:
Ted John
2017-01-12 22:11:31 +00:00
parent ae615e5d57
commit 4090522901

View File

@@ -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");