From 7b1388f85c23f2b0d6ea242f21d90a2090a50b50 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 3 Apr 2020 12:23:37 -0700 Subject: [PATCH] Fix undefined behavior when backspacing in script list with 0 scripts The problem is that it would index out-of-bounds if you did this, but this UB hasn't caused an exception until my change to refactor script-related vectors by removing their separate length-trackers. --- desktop_version/src/editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 8484d15a..4ea53dd8 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -3596,7 +3596,7 @@ void editorinput() if(!key.keymap[SDLK_BACKSPACE]) ed.deletekeyheld=0; - if(key.keymap[SDLK_BACKSPACE] && ed.deletekeyheld==0) + if(key.keymap[SDLK_BACKSPACE] && ed.deletekeyheld==0 && !ed.hooklist.empty()) { ed.deletekeyheld=1; music.playef(2);