summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-19 12:22:22 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-19 12:22:22 +0200
commit87b1990e4092e88a2bbca6e2b35d8e3f2921d685 (patch)
treed95853fb83e5d9a2933951fad561dad7c04b9ec4
parent9aa7c3ef35abeb4b9685915bdcbec9055c1e0a3c (diff)
downloadpianobar-87b1990e4092e88a2bbca6e2b35d8e3f2921d685.tar.gz
pianobar-87b1990e4092e88a2bbca6e2b35d8e3f2921d685.tar.bz2
pianobar-87b1990e4092e88a2bbca6e2b35d8e3f2921d685.zip
piano: Fix possible memory leak
*Every* xml parser uses XmlInitDoc to create a doc handle, but nobody frees it when an error is reported.
-rw-r--r--libpiano/src/xml.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libpiano/src/xml.c b/libpiano/src/xml.c
index d0faca6..33c2dde 100644
--- a/libpiano/src/xml.c
+++ b/libpiano/src/xml.c
@@ -146,7 +146,7 @@ void PianoXmlStructParser (xmlNode *structRoot,
* @param xml document
* @param returns document pointer (needed to free memory later)
* @param returns document root
- * @return _RET_ERR or _RET_OK
+ * @return _OK or error
*/
PianoReturn_t PianoXmlInitDoc (char *xml, xmlDocPtr *doc, xmlNode **docRoot) {
*doc = xmlReadDoc ((xmlChar *) xml, NULL, NULL, 0);
@@ -160,6 +160,7 @@ PianoReturn_t PianoXmlInitDoc (char *xml, xmlDocPtr *doc, xmlNode **docRoot) {
*docRoot = xmlDocGetRootElement (*doc);
if ((ret = PianoXmlIsFault (*docRoot)) != PIANO_RET_OK) {
+ xmlFreeDoc (*doc);
return ret;
}