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.
This commit is contained in:
Misa
2020-07-02 16:09:55 -07:00
committed by Ethan Lee
parent c7774a3eb9
commit c3e7ddca9c

View File

@@ -56,9 +56,13 @@ void scriptclass::tokenize( std::string t )
{ {
tempword += currentletter; tempword += currentletter;
} }
if (j >= (int) SDL_arraysize(words))
{
break;
}
} }
if (tempword != "") if (tempword != "" && j < (int) SDL_arraysize(words))
{ {
words[j] = tempword; words[j] = tempword;
} }