summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2013-03-17 07:12:23 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-17 14:55:53 -0700
commita094b2b88a21a7161def15ad0a730f79a8c83f09 (patch)
tree96f41b4ff3c0a863281bdad11d852c085a8618ed /parse-xml.c
parent38d224a335cb9935d186b8b7ad0dc39c768e364f (diff)
downloadsubsurface-a094b2b88a21a7161def15ad0a730f79a8c83f09.tar.gz
Terminate decode at end of string and fix mem leak
Seems that we have to NULL terminate the buffer for xmlStringLenDecodeEntitites() as otherwise we might end up having extra data at the end of returned buffer. (Somehow the length parameter is not respected always, even if it is the proper size returned by the zip_fread() - header_skip). Also free the buffer returned by xmlStringLenDecodeEntitites(). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c
index b24806bba..2ecd063b2 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1562,6 +1562,9 @@ void parse_xml_buffer(const char *url, const char *buffer, int size,
target_table = table;
doc = xmlReadMemory(res, strlen(res), url, NULL, 0);
+ if (res != buffer)
+ free((char *)res);
+
if (!doc) {
fprintf(stderr, _("Failed to parse '%s'.\n"), url);
parser_error(error, _("Failed to parse '%s'"), url);