From a05f2121a16368d4d7946cd65390f7668e6fbe2f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 8 May 2016 23:17:28 +0200 Subject: SCUMM HE: Safeguard division by zero --- engines/scumm/he/sound_he.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp index 9a456b86c0..2e0a03af7f 100644 --- a/engines/scumm/he/sound_he.cpp +++ b/engines/scumm/he/sound_he.cpp @@ -470,6 +470,10 @@ void SoundHE::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) { if (arg == 2) { val = getSoundVar(sound, val); } + if (!val) { + val = 1; // Safeguard for division by zero + warning("Incorrect value 0 for processSoundOpcodes() kludge DIV"); + } val = getSoundVar(sound, var) / val; setSoundVar(sound, var, val); break; -- cgit v1.2.3