summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-24 23:42:30 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-24 23:42:30 +0300
commite0ad1f9076f322f18b54c4f1e0894a9cdd52937c (patch)
treebf2c3bcc2011e8f72084875fab9151d35ad15de4
parent641b843fd85d096afdd9b171975df91676179f3b (diff)
downloadmv-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.tar.gz
mv-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.tar.bz2
mv-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.tar.xz
mv-e0ad1f9076f322f18b54c4f1e0894a9cdd52937c.zip
Fix memory corruption if use map patch layers.
-rw-r--r--src/resources/mapreader.cpp5
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,