From 5fa3232bcf3c35b74049a341f3ecaefef8a68e28 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Thu, 5 Aug 2021 12:51:59 +0100 Subject: [PATCH] AGS: Fix undefined behavior in initialization of AGSSnowRain Due to the declaration order of the member variables, the _screenWidth and _screenHeight where used before being initialized to initialize the _snow and _rain variables. This could then lead to a division by zero. This fixes bug #12771: AGS King's Quest 3 VGA from IA crashes on startup --- engines/ags/plugins/ags_snow_rain/ags_snow_rain.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/ags/plugins/ags_snow_rain/ags_snow_rain.h b/engines/ags/plugins/ags_snow_rain/ags_snow_rain.h index 705d5ac36ba..6d898c9ade3 100644 --- a/engines/ags/plugins/ags_snow_rain/ags_snow_rain.h +++ b/engines/ags/plugins/ags_snow_rain/ags_snow_rain.h @@ -37,11 +37,11 @@ namespace AGSSnowRain { class AGSSnowRain : public PluginBase { SCRIPT_HASH(AGSSnowRain) private: - Weather _rain; - Weather _snow; int32 _screenWidth = 320; int32 _screenHeight = 200; int32 _screenColorDepth = 32; + Weather _rain; + Weather _snow; private: void srSetWindSpeed(ScriptMethodParams ¶ms);