mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Fix reading uninitialized memory when creating Menu::levellist
Valgrind reported this. The error here is that the buffer here is only guaranteed to be initialized up until (and including) the null-terminator, by SDL_snprintf(). Iterating over the entire allocated buffer is bad and I should feel bad as the girl who wrote this code; doing that reads uninitialized memory and passes it to SDL_tolower(). As a bonus, the iterator increment is now a preincrement instead of a postincrement.
This commit is contained in:
parent
3226d4f312
commit
fe8d163041
1 changed files with 1 additions and 1 deletions
|
@ -6338,7 +6338,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
|
|||
}
|
||||
char text[menutextbytes];
|
||||
SDL_snprintf(text, sizeof(text), "%s%s", prefix, ed.ListOfMetaData[i].title.c_str());
|
||||
for (size_t ii = 0; ii < SDL_arraysize(text); ii++)
|
||||
for (size_t ii = 0; text[ii] != '\0'; ++ii)
|
||||
{
|
||||
text[ii] = SDL_tolower(text[ii]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue