Bugfix: if the highscore file is invalid, a double free happened.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12408 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
08c3c7487a
commit
1254dbfa9e
@ -87,6 +87,7 @@ void HighscoreManager::loadHighscores()
|
||||
if(!root || root->getName()!="highscores")
|
||||
{
|
||||
if(root) delete root;
|
||||
root = NULL;
|
||||
throw std::runtime_error("No 'highscore' node found.");
|
||||
}
|
||||
|
||||
@ -104,6 +105,7 @@ void HighscoreManager::loadHighscores()
|
||||
// calling Save() now will generate an empty file with the right format.
|
||||
saveHighscores();
|
||||
delete root;
|
||||
root = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,7 +138,8 @@ void HighscoreManager::loadHighscores()
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "No old highscores will be available.\n");
|
||||
}
|
||||
delete root;
|
||||
if(root)
|
||||
delete root;
|
||||
} // loadHighscores
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user