1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 03:23:15 +01:00

Fix #5029: Invalid window limit can cause crash

#5121
This commit is contained in:
wolfreak99
2017-01-29 13:03:23 -05:00
committed by Ted John
parent 751395670c
commit 70a855c395
2 changed files with 10 additions and 1 deletions

View File

@@ -544,6 +544,15 @@ bool config_open(const utf8string path)
free(lineBuffer);
SDL_RWclose(file);
// Window limit must be kept within valid range.
if (gConfigGeneral.window_limit < WINDOW_LIMIT_MIN) {
gConfigGeneral.window_limit = WINDOW_LIMIT_MIN;
}
else if (gConfigGeneral.window_limit > WINDOW_LIMIT_MAX) {
gConfigGeneral.window_limit = WINDOW_LIMIT_MAX;
}
return true;
}

View File

@@ -379,7 +379,7 @@ static void window_close_surplus(sint32 cap, sint8 avoid_classification)
void window_set_window_limit(sint32 value)
{
sint32 prev = gConfigGeneral.window_limit;
sint32 val = clamp(value, WINDOW_LIMIT_MIN, WINDOW_LIMIT_MAX);
sint32 val = clamp(WINDOW_LIMIT_MIN, value, WINDOW_LIMIT_MAX);
gConfigGeneral.window_limit = val;
config_save_default();
// Checks if value decreases and then closes surplus