summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-06-29 18:43:13 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-06-29 18:43:13 (GMT)
commitb5821557899dc5bd0eca1f7430211730b6781e0f (patch)
treed66620425f5b761a7f95f0f708e8eef73ee6d10f /Modules
parent305e49e17edd6870b52af547a6c6cbf613864d05 (diff)
downloadcpython-b5821557899dc5bd0eca1f7430211730b6781e0f.zip
cpython-b5821557899dc5bd0eca1f7430211730b6781e0f.tar.gz
cpython-b5821557899dc5bd0eca1f7430211730b6781e0f.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/pyexpat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 01ac14e..3039347 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);