diff options
author | Ira Rice <irarice@gmail.com> | 2008-12-03 13:20:58 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-12-03 13:20:58 -0700 |
commit | 7d6c6b7a5711536bbb8262312457b8422cf883bb (patch) | |
tree | 6684f008c16eaaff01b86f8d826a59b370818249 /src/resources/colordb.cpp | |
parent | 72b42a7da7580e0eb52170f3d6c7d49dc0925e98 (diff) | |
download | mana-client-7d6c6b7a5711536bbb8262312457b8422cf883bb.tar.gz mana-client-7d6c6b7a5711536bbb8262312457b8422cf883bb.tar.bz2 mana-client-7d6c6b7a5711536bbb8262312457b8422cf883bb.tar.xz mana-client-7d6c6b7a5711536bbb8262312457b8422cf883bb.zip |
Check doc before deleting, and make sure it's deleted when both xml
files fail, if the pointer is pointing to something.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/resources/colordb.cpp')
-rw-r--r-- | src/resources/colordb.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index d9c76f18..46acaf39 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -55,7 +55,10 @@ void ColorDB::load() logger->log("Trying TMW's color file, %s.", TMW_COLOR_FILE); TMWHair = true; - delete doc; + + if (doc) + delete doc; + doc = new XML::Document(TMW_COLOR_FILE); root = doc->rootNode(); if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) @@ -63,6 +66,10 @@ void ColorDB::load() logger->log("ColorDB: Failed"); mColors[0] = mFail; mLoaded = true; + + if (doc) + delete doc; + return; } } @@ -84,7 +91,9 @@ void ColorDB::load() } } - delete doc; + if (doc) + delete doc; + mLoaded = true; } |