Commits

Nick Wellnhofer committed 0488f99

Fix potential memory leaks when freeing parse context

Comments (0)

Files changed (1)

             }
 
             PmmSAXCloseContext(ctxt);
+            if (ctxt->myDoc != NULL) {
+                /* Not freed by xmlFreeParserCtxt */
+                xmlFreeDoc(ctxt->myDoc);
+            }
             xmlFreeParserCtxt(ctxt);
         }
 
             ctxt->sax = NULL;
             xmlFree(sax);
             PmmSAXCloseContext(ctxt);
+            if (ctxt->myDoc != NULL) {
+                /* Not freed by xmlFreeParserCtxt */
+                xmlFreeDoc(ctxt->myDoc);
+            }
             xmlFreeParserCtxt(ctxt);
         }
         CLEANUP_ERROR_HANDLER;
             }
 
             PmmSAXCloseContext(ctxt);
+            if (ctxt->myDoc != NULL) {
+                /* Not freed by xmlFreeParserCtxt */
+                xmlFreeDoc(ctxt->myDoc);
+            }
             xmlFreeParserCtxt(ctxt);
         }
 
 
             xmlFree( handler );
             PmmSAXCloseContext(ctxt);
+            if (ctxt->myDoc != NULL) {
+                /* Not freed by xmlFreeParserCtxt */
+                xmlFreeDoc(ctxt->myDoc);
+            }
             xmlFreeParserCtxt(ctxt);
 
             /* free the chunk we created */