Fix memory leaks for xmlACatalogAdd
Libxml2:Memory leak in xmlcatalog.c:460,xmlcatalog.c:453 and xmlcatalog.c:462.
Commands Triggering Memory Leakage:
xmlcatalog --sgml --add entry SGML
xmlcatalog --sgml --add
[root@localhost ~]# rpm -qa libxml2
libxml2-2.9.12-6.aarch64
[root@localhost ~]#
[root@localhost ~]# valgrind --tool=memcheck --leak-check=full xmlcatalog --sgml --add 'entry' SGML > xml2test
==35793== Memcheck, a memory error detector
==35793== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==35793== Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info
==35793== Command: xmlcatalog --sgml --add entry SGML
==35793==
==35793==
==35793== HEAP SUMMARY:
==35793== in use at exit: 1,446 bytes in 12 blocks
==35793== total heap usage: 33 allocs, 21 frees, 6,532 bytes allocated
==35793==
==35793== 722 (120 direct, 602 indirect) bytes in 1 blocks are definitely lost in loss record 11 of 12
==35793== at 0x4866EC0: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-arm64-linux.so)
==35793== by 0x4928E9B: xmlCreateNewCatalog (catalog.c:418)
==35793== by 0x492D343: xmlNewCatalog__internal_alias (catalog.c:3028)
==35793== by 0x492D343: xmlNewCatalog (catalog.c:3024)
==35793== by 0x109B8B: main (xmlcatalog.c:453)
==35793==
==35793== 724 (120 direct, 604 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 12
==35793== at 0x4866EC0: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-arm64-linux.so)
==35793== by 0x4928E9B: xmlCreateNewCatalog (catalog.c:418)
==35793== by 0x492D343: xmlNewCatalog__internal_alias (catalog.c:3028)
==35793== by 0x492D343: xmlNewCatalog (catalog.c:3024)
==35793== by 0x109CA7: main (xmlcatalog.c:460)
==35793==
==35793== LEAK SUMMARY:
==35793== definitely lost: 240 bytes in 2 blocks
==35793== indirectly lost: 1,206 bytes in 10 blocks
==35793== possibly lost: 0 bytes in 0 blocks
==35793== still reachable: 0 bytes in 0 blocks
==35793== suppressed: 0 bytes in 0 blocks
==35793==
==35793== For lists of detected and suppressed errors, rerun with: -s
==35793== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# valgrind --tool=memcheck --leak-check=full xmlcatalog --sgml --add
==3714828== Memcheck, a memory error detector
==3714828== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3714828== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==3714828== Command: xmlcatalog --sgml --add
==3714828==
CATALOG "SHELL=/bin/bash"
==3714828==
==3714828== HEAP SUMMARY:
==3714828== in use at exit: 3,784 bytes in 59 blocks
==3714828== total heap usage: 110 allocs, 51 frees, 7,214 bytes allocated
==3714828==
==3714828== 80 bytes in 1 blocks are definitely lost in loss record 6 of 14
==3714828== at 0x4868048: malloc (vg_replace_malloc.c:380)
==3714828== by 0x4939997: ??? (in /usr/lib64/libxml2.so.2.9.12)
==3714828== by 0x493CB67: xmlACatalogAdd (in /usr/lib64/libxml2.so.2.9.12)
==3714828== by 0x109ADF: main (xmlcatalog.c:462)
==3714828==
==3714828== 744 (120 direct, 624 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 14
==3714828== at 0x4868048: malloc (vg_replace_malloc.c:380)
==3714828== by 0x4938CDB: ??? (in /usr/lib64/libxml2.so.2.9.12)
==3714828== by 0x493D1A3: xmlNewCatalog (in /usr/lib64/libxml2.so.2.9.12)
==3714828== by 0x109C73: main (xmlcatalog.c:453)
==3714828==
==3714828== 2,960 (120 direct, 2,840 indirect) bytes in 1 blocks are definitely lost in loss record 14 of 14
==3714828== at 0x4868048: malloc (vg_replace_malloc.c:380)
==3714828== by 0x4938CDB: ??? (in /usr/lib64/libxml2.so.2.9.12)
==3714828== by 0x493C4CF: xmlLoadSGMLSuperCatalog (in /usr/lib64/libxml2.so.2.9.12)
==3714828== by 0x109ABF: main (xmlcatalog.c:458)
==3714828==
==3714828== LEAK SUMMARY:
==3714828== definitely lost: 320 bytes in 3 blocks
==3714828== indirectly lost: 3,464 bytes in 56 blocks
==3714828== possibly lost: 0 bytes in 0 blocks
==3714828== still reachable: 0 bytes in 0 blocks
==3714828== suppressed: 0 bytes in 0 blocks
==3714828==
==3714828== For lists of detected and suppressed errors, rerun with: -s
==3714828== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
[root@localhost ~]#