mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Fix level list segfault when upgrading old levelstats.vvv
So some people reported the levels list crashing when they loaded it. But this wasn't reproducible every time. They didn't provide any debugging information, so I had to use my backup plan: doing a full audit of the code path taken for loading the levels list. And then I found this. It turns out this was because I used a LOAD_ARRAY_RENAME() macro on an std::vector. You can't do that because you need to use push_back() to resize a vector, so the macro will end up indexing into nothing, causing a segfault. However, this code path would only be taken if you have an old levelstats.vvv, from 2.2 and previous - which explains why it wasn't 100% reproducible. But now that I know you need an old levelstats.vvv, this bug happens 100% of the time. Anyways, to fix this, just ditch the macro and expand it manually, while replacing the indexing with a proper usage of push_back().
This commit is contained in:
parent
0f0e218cf6
commit
f96f5703ff
1 changed files with 10 additions and 1 deletions
|
@ -556,7 +556,16 @@ void Game::loadcustomlevelstats(void)
|
||||||
pText = "";
|
pText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
LOAD_ARRAY_RENAME(customlevelscore, customlevelscores)
|
if (SDL_strcmp(pKey, "customlevelscore") == 0 && pText[0] != '\0')
|
||||||
|
{
|
||||||
|
char buffer[16];
|
||||||
|
size_t start = 0;
|
||||||
|
|
||||||
|
while (next_split_s(buffer, sizeof(buffer), &start, pText, ','))
|
||||||
|
{
|
||||||
|
customlevelscores.push_back(help.Int(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_strcmp(pKey, "customlevelstats") == 0 && pText[0] != '\0')
|
if (SDL_strcmp(pKey, "customlevelstats") == 0 && pText[0] != '\0')
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue