From c3e7ddca9c5e77651234550fda140d26c4faee45 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 2 Jul 2020 16:09:55 -0700 Subject: [PATCH] Add bounds checks to scriptclass::tokenize() It could index the `words` array out-of-bounds if there were more than 40 arguments in a command. Not like that would ever happen, but it's still good to be sure. --- desktop_version/src/Script.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index b564392f..ab6d526b 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -56,9 +56,13 @@ void scriptclass::tokenize( std::string t ) { tempword += currentletter; } + if (j >= (int) SDL_arraysize(words)) + { + break; + } } - if (tempword != "") + if (tempword != "" && j < (int) SDL_arraysize(words)) { words[j] = tempword; }