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
1 changed files with 7 additions and 0 deletions

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