diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 035070cf..1d7bad14 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -4728,7 +4728,13 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, struct ScreenSett if (SDL_strcmp(pKey, "stretch") == 0) { - screen_settings->scalingMode = help.Int(pText); + int mode = help.Int(pText); + if (mode < 0 || mode >= NUM_SCALING_MODES) + { + /* Pick a sane default. */ + mode = SCALING_INTEGER; + } + screen_settings->scalingMode = mode; } if (SDL_strcmp(pKey, "useLinearFilter") == 0) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index ed5c93f1..7d7489e5 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -3517,6 +3517,13 @@ void Graphics::get_stretch_info(SDL_Rect* rect) rect->w = width; rect->h = height; break; + default: + SDL_assert(0 && "Invalid scaling mode!"); + /* Width and height should be nonzero to avoid division by zero. */ + rect->x = 0; + rect->y = 0; + rect->w = width; + rect->h = height; } }