diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-03 18:31:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-03 18:31:34 +0300 |
commit | 3e49f45ae0d8971cb3870f388d55ea67ff127400 (patch) | |
tree | 0a90f76d52f568a9c592f97b44be84dd4d7c47b0 | |
parent | 2d810704bfd100e9565d791fb3681f26c8894a9a (diff) | |
download | manaplus-3e49f45ae0d8971cb3870f388d55ea67ff127400.tar.gz manaplus-3e49f45ae0d8971cb3870f388d55ea67ff127400.tar.bz2 manaplus-3e49f45ae0d8971cb3870f388d55ea67ff127400.tar.xz manaplus-3e49f45ae0d8971cb3870f388d55ea67ff127400.zip |
Fix memory leak in mapreader class.
-rw-r--r-- | src/resources/mapreader.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index fb0298457..098af0909 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -498,8 +498,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) int len = static_cast<int>(strlen( reinterpret_cast<const char*>(dataChild->content)) + 1); unsigned char *charData = new unsigned char[len + 1]; - const char *charStart = reinterpret_cast<const char*>( - xmlNodeGetContent(dataChild)); + xmlChar *xmlChars = xmlNodeGetContent(dataChild); + const char *charStart = reinterpret_cast<const char*>(xmlChars); if (!charStart) { delete[] charData; @@ -526,6 +526,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) charData))), &binLen); delete[] charData; + xmlFree(xmlChars); if (binData) { @@ -579,8 +580,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) if (!dataChild) continue; - const char *data = reinterpret_cast<const char*>( - xmlNodeGetContent(dataChild)); + xmlChar *xmlChars = xmlNodeGetContent(dataChild); + const char *data = reinterpret_cast<const char*>(xmlChars); if (!data) return; @@ -611,6 +612,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) oldPos = pos + 1; } + xmlFree(xmlChars); } else { |