diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-24 23:42:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-24 23:42:30 +0300 |
commit | e0ad1f9076f322f18b54c4f1e0894a9cdd52937c (patch) | |
tree | bf2c3bcc2011e8f72084875fab9151d35ad15de4 /src/resources/mapreader.cpp | |
parent | 641b843fd85d096afdd9b171975df91676179f3b (diff) | |
download | manaverse-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.tar.gz manaverse-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.tar.bz2 manaverse-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.tar.xz manaverse-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.zip |
Fix memory corruption if use map patch layers.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r-- | src/resources/mapreader.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 4da901b09..6d7591d1d 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -202,6 +202,7 @@ void MapReader::addLayerToList(const std::string &fileName) return; } + int cnt = 0; for_each_xml_child_node(childNode, node) { if (!xmlNameEqual(childNode, "layer")) @@ -213,8 +214,10 @@ void MapReader::addLayerToList(const std::string &fileName) logger->log("found patch layer: " + name); mKnownLayers[name] = childNode; mKnownDocs.insert(doc); + cnt ++; } - delete doc; + if (!cnt) + delete doc; } Map *MapReader::readMap(const std::string &restrict filename, |