yaz-marcdump: fix leaks for MARCXML parsing YAZ-694
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 27 Sep 2013 11:47:20 +0000 (13:47 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 27 Sep 2013 11:47:20 +0000 (13:47 +0200)
util/marcdump.c

index f92204e..891174b 100644 (file)
@@ -133,8 +133,7 @@ static void marcdump_read_xml(yaz_marc_t mt, const char *fname)
             int type = xmlTextReaderNodeType(reader);
             if (type == XML_READER_TYPE_ELEMENT)
             {
-                const char *name = (const char *)
-                    xmlTextReaderLocalName(reader);
+                char *name = (char *) xmlTextReaderLocalName(reader);
                 if (!strcmp(name, "record") || !strcmp(name, "r"))
                 {
                     xmlNodePtr ptr = xmlTextReaderExpand(reader);
@@ -158,8 +157,10 @@ static void marcdump_read_xml(yaz_marc_t mt, const char *fname)
                         wrbuf_rewind(wrbuf);
                     }
                 }
+                xmlFree(name);
             }
         }
+        xmlFreeTextReader(reader);
     }
 #else
     xmlDocPtr doc = xmlParseFile(fname);