xmllint: Fix memory leak in error case

This commit is contained in:
Nick Wellnhofer 2025-01-17 13:04:35 +01:00
parent fbaacfe223
commit 0f4d36e055

View File

@ -2578,6 +2578,9 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr pctxt) {
xmlDebugDumpEntities(ERR_STREAM, doc); xmlDebugDumpEntities(ERR_STREAM, doc);
#endif #endif
/* Avoid unused label warning */
goto done;
done: done:
/* /*
* free it. * free it.
@ -3490,6 +3493,9 @@ xmllintMain(int argc, const char **argv, xmlResourceLoader loader) {
usage(ERR_STREAM, argv[0]); usage(ERR_STREAM, argv[0]);
progresult = XMLLINT_ERR_UNCLASS; progresult = XMLLINT_ERR_UNCLASS;
} }
error:
#ifdef LIBXML_SCHEMATRON_ENABLED #ifdef LIBXML_SCHEMATRON_ENABLED
if (wxschematron != NULL) if (wxschematron != NULL)
xmlSchematronFree(wxschematron); xmlSchematronFree(wxschematron);
@ -3505,10 +3511,6 @@ xmllintMain(int argc, const char **argv, xmlResourceLoader loader) {
xmlFreePattern(patternc); xmlFreePattern(patternc);
#endif #endif
/* Avoid unused label warning if features are disabled. */
goto error;
error:
xmlCleanupParser(); xmlCleanupParser();
return(progresult); return(progresult);