1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 10:38:31 +02:00

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.
This commit is contained in:
Misa 2020-05-27 00:40:24 -07:00 committed by Ethan Lee
parent ff6cc1a777
commit cfcfccf58b

View File

@ -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<nti; ti2++){
i++; add(customscript[i]);
i++;
if(i < (int) customscript.size()){
add(customscript[i]);
}
}
switch(speakermode){
@ -3816,7 +3822,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<nti; ti2++){
i++; add(customscript[i]);
i++;
if(i < (int) customscript.size()){
add(customscript[i]);
}
}
add("position(player,above)");
add("speak_active");