1From c9e4c6d416d00968f2e2d7c68a9c0e809265baf2 Mon Sep 17 00:00:00 2001 2From: Nick Wellnhofer <wellnhofer@aevum.de> 3Date: Tue, 21 Feb 2023 15:22:01 +0100 4Subject: [PATCH] catalog: Fix memory leaks 5 6Fixes #377. 7 8Reference:https://github.com/GNOME/libxml2/commit/c9e4c6d416d00968f2e2d7c68a9c0e809265baf2 9Conflict:catalog.c xmlcatalog.c 10 11--- 12 catalog.c | 2 +- 13 xmlcatalog.c | 6 ++---- 14 2 files changed, 3 insertions(+), 5 deletions(-) 15 16diff --git a/catalog.c b/catalog.c 17index b3a97da..4d84a6a 100644 18--- a/catalog.c 19+++ b/catalog.c 20@@ -2983,7 +2983,7 @@ xmlACatalogAdd(xmlCatalogPtr catal, const xmlChar * type, 21 if (catal->sgml == NULL) 22 catal->sgml = xmlHashCreate(10); 23 res = xmlHashAddEntry(catal->sgml, orig, entry); 24- if (res) 25+ if (res < 0) 26 xmlFreeCatalogEntry(entry, NULL); 27 } 28 } 29diff --git a/xmlcatalog.c b/xmlcatalog.c 30index 7fe25ac..c7a1dc8 100644 31--- a/xmlcatalog.c 32+++ b/xmlcatalog.c 33@@ -513,10 +513,8 @@ int main(int argc, char **argv) { 34 } 35 i += 2; 36 /* Check for memory leaks */ 37- if (catal != NULL) 38- xmlFreeCatalog(catal); 39- if (super != NULL) 40- xmlFreeCatalog(super); 41+ xmlFreeCatalog(catal); 42+ xmlFreeCatalog(super); 43 } else { 44 if ((!strcmp(argv[i], "-add")) || 45 (!strcmp(argv[i], "--add"))) { 46-- 472.27.0 48 49