Fix #15466: Crash when opening dropdown with 0 rows

This commit is contained in:
Michael Steenbeek 2021-10-20 18:50:21 +02:00 committed by GitHub
parent b762cb26ed
commit 62a9096079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -33,6 +33,7 @@
- Fix: [#15322] Circus music doesn't play.
- Fix: [#15377] Entrance/exit ghost doesn't work on different stations without touching them first.
- Fix: [#15451] Guest list name filter remains after group selection.
- Fix: [#15466] Crash when opening a dropdown with 0 rows.
- Fix: [#15476] Crash when placing/clearing small scenery.
- Fix: [#15487] Map animations do not work correctly when loading an exported SV6 file in vanilla RCT2.
- Fix: [#15490] Tile inspector needlessly updates clearance height when changing surface slopes.

View File

@ -157,7 +157,7 @@ void WindowDropdownShowTextCustomWidth(
if (gDropdownNumItems == 0)
{
_dropdown_num_columns = 1;
_dropdown_num_rows = 0;
_dropdown_num_rows = 1;
}
else
{
@ -231,15 +231,15 @@ void WindowDropdownShowImage(
_dropdown_item_width = itemWidth;
_dropdown_item_height = itemHeight;
gDropdownNumItems = numItems;
// There must always be at least one column to prevent dividing by zero
// There must always be at least one column and row to prevent dividing by zero
if (gDropdownNumItems == 0)
{
_dropdown_num_columns = 1;
_dropdown_num_rows = 0;
_dropdown_num_rows = 1;
}
else
{
_dropdown_num_columns = numColumns;
_dropdown_num_columns = std::max(1, numColumns);
_dropdown_num_rows = gDropdownNumItems / _dropdown_num_columns;
if (gDropdownNumItems % _dropdown_num_columns != 0)
_dropdown_num_rows++;