From a623190b09a4af6e5acb60a90617d26aca447ee3 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 23 May 2020 12:47:56 -0700 Subject: [PATCH] Fix using speak/speak_active without a `text` beforehand Otherwise, it would end up indexing a vector out-of-bounds, which is UB and causes a segfault, too. This is used in some constructs like say(-1) where the text contents don't matter, only that a text box shows up. --- desktop_version/src/Script.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index c4e9095d..b7a6e95e 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -577,6 +577,10 @@ void scriptclass::run() { //Ok, actually display the textbox we've initilised now! //If using "speak", don't make the textbox active (so we can use multiple textboxes) + if (txt.empty()) + { + txt.resize(1); + } graphics.createtextbox(txt[0], textx, texty, r, g, b); if ((int) txt.size() > 1) {