[Python-checkins] cpython: Fix another refleak

antoine.pitrou python-checkins at python.org
Mon Apr 16 22:07:37 CEST 2012


http://hg.python.org/cpython/rev/9d8839289e18
changeset:   76362:9d8839289e18
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon Apr 16 22:06:21 2012 +0200
summary:
  Fix another refleak

files:
  Python/import.c |  10 +++++++---
  1 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -2881,11 +2881,15 @@
                 Py_INCREF(final_mod);
             }
             else {
-                Py_ssize_t cut_off = PyUnicode_GetLength(name) -
-                                        PyUnicode_GetLength(front);
-                Py_ssize_t abs_name_len = PyUnicode_GetLength(abs_name);
+                Py_ssize_t cut_off = PyUnicode_GET_LENGTH(name) -
+                                        PyUnicode_GET_LENGTH(front);
+                Py_ssize_t abs_name_len = PyUnicode_GET_LENGTH(abs_name);
                 PyObject *to_return = PyUnicode_Substring(abs_name, 0,
                                                         abs_name_len - cut_off);
+                Py_DECREF(front);
+                if (to_return == NULL) {
+                    goto error_with_unlock;
+                }
 
                 final_mod = PyDict_GetItem(interp->modules, to_return);
                 Py_DECREF(to_return);

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


More information about the Python-checkins mailing list