]> granicus.if.org Git - python/commitdiff
Fix memory leak in pyexpat PyUnknownEncodingHandler
authorChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 18:43:13 +0000 (20:43 +0200)
committerChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 18:43:13 +0000 (20:43 +0200)
CID 1040367 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable u going out of scope leaks the storage it points to.

Modules/pyexpat.c

index 01ac14ee6cde51295d5fe569d3fd8249d5e5e1b7..303934709a323d22f51ffa82015ff1abf1a3acf1 100644 (file)
@@ -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);