From: Christian Heimes Date: Sat, 29 Jun 2013 18:43:13 +0000 (+0200) Subject: Fix memory leak in pyexpat PyUnknownEncodingHandler X-Git-Tag: v3.4.0a1~365 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5821557899dc5bd0eca1f7430211730b6781e0f;p=python Fix memory leak in pyexpat PyUnknownEncodingHandler CID 1040367 (#1 of 1): Resource leak (RESOURCE_LEAK) leaked_storage: Variable u going out of scope leaks the storage it points to. --- diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 01ac14ee6c..303934709a 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1128,8 +1128,10 @@ PyUnknownEncodingHandler(void *encodingHandlerData, } u = PyUnicode_Decode((char*) template_buffer, 256, name, "replace"); - if (u == NULL || PyUnicode_READY(u)) + if (u == NULL || PyUnicode_READY(u)) { + Py_DECREF(u); return XML_STATUS_ERROR; + } if (PyUnicode_GET_LENGTH(u) != 256) { Py_DECREF(u);