mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01: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:
parent
ff6cc1a777
commit
cfcfccf58b
1 changed files with 12 additions and 3 deletions
|
@ -376,7 +376,10 @@ void scriptclass::run()
|
||||||
for (int i = 0; i < ss_toi(words[4]); i++)
|
for (int i = 0; i < ss_toi(words[4]); i++)
|
||||||
{
|
{
|
||||||
position++;
|
position++;
|
||||||
txt.push_back(commands[position]);
|
if (position < (int) commands.size())
|
||||||
|
{
|
||||||
|
txt.push_back(commands[position]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (words[0] == "position")
|
else if (words[0] == "position")
|
||||||
|
@ -3794,7 +3797,10 @@ void scriptclass::loadcustom(std::string t)
|
||||||
int ti=atoi(words[1].c_str());
|
int ti=atoi(words[1].c_str());
|
||||||
int nti = ti>=0 && ti<=50 ? ti : 1;
|
int nti = ti>=0 && ti<=50 ? ti : 1;
|
||||||
for(int ti2=0; ti2<nti; ti2++){
|
for(int ti2=0; ti2<nti; ti2++){
|
||||||
i++; add(customscript[i]);
|
i++;
|
||||||
|
if(i < (int) customscript.size()){
|
||||||
|
add(customscript[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(speakermode){
|
switch(speakermode){
|
||||||
|
@ -3816,7 +3822,10 @@ void scriptclass::loadcustom(std::string t)
|
||||||
int ti=atoi(words[1].c_str());
|
int ti=atoi(words[1].c_str());
|
||||||
int nti = ti>=0 && ti<=50 ? ti : 1;
|
int nti = ti>=0 && ti<=50 ? ti : 1;
|
||||||
for(int ti2=0; ti2<nti; ti2++){
|
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("position(player,above)");
|
||||||
add("speak_active");
|
add("speak_active");
|
||||||
|
|
Loading…
Reference in a new issue