[Python-checkins] cpython: Issue #17693: Fix memory/reference leaks

victor.stinner python-checkins at python.org
Sun Apr 14 19:31:40 CEST 2013


http://hg.python.org/cpython/rev/ffd4b72f7f95
changeset:   83382:ffd4b72f7f95
parent:      83380:227fed7a05d4
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sun Apr 14 18:11:41 2013 +0200
summary:
  Issue #17693: Fix memory/reference leaks

files:
  Modules/cjkcodecs/multibytecodec.c |  8 +++-----
  1 files changed, 3 insertions(+), 5 deletions(-)


diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -738,7 +738,6 @@
     PyObject *inbuf = NULL;
     Py_ssize_t inpos, datalen;
     PyObject *origpending = NULL;
-    wchar_t *data;
 
     if (PyUnicode_Check(unistr))
         ucvt = NULL;
@@ -754,10 +753,6 @@
         }
     }
 
-    data = PyUnicode_AsUnicodeAndSize(unistr, &datalen);
-    if (data == NULL)
-        goto errorexit;
-
     if (ctx->pending) {
         PyObject *inbuf_tmp;
 
@@ -793,6 +788,7 @@
         origpending = NULL;
         goto errorexit;
     }
+    Py_XDECREF(origpending);
 
     if (inpos < datalen) {
         if (datalen - inpos > MAXENCPENDING) {
@@ -808,6 +804,7 @@
         }
     }
 
+    Py_DECREF(inbuf);
     Py_XDECREF(ucvt);
     return r;
 
@@ -815,6 +812,7 @@
     Py_XDECREF(r);
     Py_XDECREF(ucvt);
     Py_XDECREF(origpending);
+    Py_XDECREF(inbuf);
     return NULL;
 }
 

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


More information about the Python-checkins mailing list