[Python-checkins] cpython: Fix memory leak introduced in 15190138d3f3.

ezio.melotti python-checkins at python.org
Thu Mar 7 20:19:16 CET 2013


http://hg.python.org/cpython/rev/c261b74533bf
changeset:   82533:c261b74533bf
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Thu Mar 07 21:18:45 2013 +0200
summary:
  Fix memory leak introduced in 15190138d3f3.

files:
  Modules/_testcapimodule.c |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1423,11 +1423,15 @@
     if (wide == NULL)
         return NULL;
     PyUnicode_AS_UNICODE(wide)[0] = invalid[0];
-    if (_PyUnicode_Ready(wide) < 0)
+    if (_PyUnicode_Ready(wide) < 0) {
+        Py_DECREF(wide);
         PyErr_Clear();
-    else
+    }
+    else {
+        Py_DECREF(wide);
         return raiseTestError("test_widechar",
                               "PyUnicode_Ready() didn't fail");
+    }
 #endif
 
     Py_RETURN_NONE;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list