From 4034c228336d3d19c7ab58380bf10895092e4784 Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 19 May 2020 17:20:46 -0700 Subject: [PATCH] Add bounds checks to roomdeaths and roomdeathsfinal This fixes being able to trigger Undefined Behavior by pressing R when not in-bounds in the Outside Dimension VVVVVV map, usually when you're falling upwards towards Game Complete. I also put bounds checks on normal roomdeaths for good measure. You'll never know when you need it. --- desktop_version/src/Game.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index fc302902..bb5a2e86 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -4799,13 +4799,19 @@ void Game::deathsequence() obj.entities[i].invis = true; if (map.finalmode) { - map.roomdeathsfinal[roomx - 41 + (20 * (roomy - 48))]++; - currentroomdeaths = map.roomdeathsfinal[roomx - 41 + (20 * (roomy - 48))]; + if (roomx - 41 >= 0 && roomx - 41 < 20 && roomy - 48 >= 0 && roomy - 48 < 20) + { + map.roomdeathsfinal[roomx - 41 + (20 * (roomy - 48))]++; + currentroomdeaths = map.roomdeathsfinal[roomx - 41 + (20 * (roomy - 48))]; + } } else { - map.roomdeaths[roomx - 100 + (20*(roomy - 100))]++; - currentroomdeaths = map.roomdeaths[roomx - 100 + (20 * (roomy - 100))]; + if (roomx - 100 >= 0 && roomx - 100 < 20 && roomy - 100 >= 0 && roomy - 100 < 20) + { + map.roomdeaths[roomx - 100 + (20*(roomy - 100))]++; + currentroomdeaths = map.roomdeaths[roomx - 100 + (20 * (roomy - 100))]; + } } } if (deathseq == 25) obj.entities[i].invis = true;