mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01:00
Add bounds check to textcase() command
This makes it so that only inputs between 1 and 255 inclusive will be accepted. Otherwise, the command has no effect. This is because the text case is stored as one byte in a string, and a value of zero would be the null terminator. We also want to minimize potential weirdness with integer wrapping if we accept inputs from outside those bounds. While the textcase variable as used throughout the codebase is plain unqualified `char` (which, unlike other integers, exists in a quantum superposition of being signed and unsigned depending on compiler, machine, and various other stuff) and so there still might be issues there, we definitely don't want anything higher than 255.
This commit is contained in:
parent
34e7b1af61
commit
67df8a9679
1 changed files with 5 additions and 1 deletions
|
@ -2457,7 +2457,11 @@ void scriptclass::run(void)
|
||||||
else if (words[0] == "textcase")
|
else if (words[0] == "textcase")
|
||||||
{
|
{
|
||||||
// Used to disambiguate identical textboxes for translations (1 by default)
|
// Used to disambiguate identical textboxes for translations (1 by default)
|
||||||
textcase = ss_toi(words[1]);
|
const int number = ss_toi(words[1]);
|
||||||
|
if (number >= 1 && number <= 255)
|
||||||
|
{
|
||||||
|
textcase = number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (words[0] == "loadtext")
|
else if (words[0] == "loadtext")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue