From a6b076e2342d5bc4367b25b5dedc66f3c1d2bb0b Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 25 Dec 2021 00:22:22 -0800 Subject: [PATCH] Explicitly zero declared `struct ScreenSettings`s Performance cost is negligible and well worth being safe in case there are more members added in the future but we forget to initialize them. --- desktop_version/src/Game.cpp | 2 ++ desktop_version/src/main.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 81ce0c9c..92100071 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -4328,6 +4328,7 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, struct ScreenSett bool Game::savestats(bool sync /*= true*/) { struct ScreenSettings screen_settings; + SDL_zero(screen_settings); gameScreen.GetSettings(&screen_settings); return savestats(&screen_settings, sync); @@ -4593,6 +4594,7 @@ void Game::loadsettings(struct ScreenSettings* screen_settings) bool Game::savesettings(void) { struct ScreenSettings screen_settings; + SDL_zero(screen_settings); gameScreen.GetSettings(&screen_settings); return savesettings(&screen_settings); diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 0e4402d8..3ef56eff 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -572,6 +572,7 @@ int main(int argc, char *argv[]) // Prioritize unlock.vvv first (2.2 and below), // but settings have been migrated to settings.vvv (2.3 and up) struct ScreenSettings screen_settings; + SDL_zero(screen_settings); ScreenSettings_default(&screen_settings); game.loadstats(&screen_settings); game.loadsettings(&screen_settings);