From cfcfccf58b4f2041fe024350093efaa2abe5fb42 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 27 May 2020 00:40:24 -0700 Subject: [PATCH] Fix segfault if say/reply/text asks for more lines than there are This commit adds bounds checks to those commands in case say()/reply() asks for more lines than there are left in the all-script-lines buffer (not just the current script, so in order for it to segfault your script has to be last in the all-script-lines vector), and in case text() asks for more lines than there are in the rest of the rest of the parsed internal script. --- desktop_version/src/Script.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index ffd23668..873265e4 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -376,7 +376,10 @@ void scriptclass::run() for (int i = 0; i < ss_toi(words[4]); i++) { position++; - txt.push_back(commands[position]); + if (position < (int) commands.size()) + { + txt.push_back(commands[position]); + } } } else if (words[0] == "position") @@ -3794,7 +3797,10 @@ void scriptclass::loadcustom(std::string t) int ti=atoi(words[1].c_str()); int nti = ti>=0 && ti<=50 ? ti : 1; for(int ti2=0; ti2=0 && ti<=50 ? ti : 1; for(int ti2=0; ti2