[PATCH 5/5] parse-xml.c: fixed a small memory leak related to xmlGetProp()
Lubomir I. Ivanov
neolit123 at gmail.com
Wed Feb 20 17:07:22 PST 2013
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
test_xslt_transforms():
xmlGetProp uses strdup(), so we have to clear the memory if a pointer
is returned.
xmlFree() doesn't seem very portable (strangly enought), so we
use free(..) directly.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
parse-xml.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/parse-xml.c b/parse-xml.c
index 2f35a4f..b44d992 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1549,8 +1549,13 @@ xmlDoc *test_xslt_transforms(xmlDoc *doc)
if (info->root) {
attribute = xmlGetProp(xmlFirstElementChild(root_element), "name");
- if (attribute && (strcasecmp(attribute, "subsurface") == 0))
- return doc;
+ if (attribute) {
+ if (strcasecmp(attribute, "subsurface") == 0) {
+ free((void *)attribute);
+ return doc;
+ }
+ free((void *)attribute);
+ }
xmlSubstituteEntitiesDefault(1);
xslt = get_stylesheet(info->file);
--
1.7.11.msysgit.0
More information about the subsurface
mailing list