[libxml2/2.9] Fix memory leak in xmlFindCharEncodingHandler



commit c7dfba9cf4f0a03510bc6c850679d7550738ff02
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Sat Mar 5 18:23:34 2022 +0100

    Fix memory leak in xmlFindCharEncodingHandler
    
    Fix memory leak in an unlikely error condition. Thanks to Wentao Liang
    for the report.
    
    Fixes #342.

 encoding.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/encoding.c b/encoding.c
index 3741c94e..c14c9ff6 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1738,6 +1738,10 @@ xmlFindCharEncodingHandler(const char *name) {
     } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
            xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
                    "iconv : problems with filters for '%s'\n", name);
+           if (icv_in != (iconv_t) -1)
+               iconv_close(icv_in);
+           else
+               iconv_close(icv_out);
     }
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]