[Python-checkins] cpython: Fix memory leak in endswith

christian.heimes python-checkins at python.org
Sat Jun 29 20:41:22 CEST 2013


http://hg.python.org/cpython/rev/787b0f99d77b
changeset:   84374:787b0f99d77b
user:        Christian Heimes <christian at cheimes.de>
date:        Sat Jun 29 20:41:06 2013 +0200
summary:
  Fix memory leak in endswith
CID 1040368 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.

files:
  Objects/unicodeobject.c |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -12941,9 +12941,9 @@
         return NULL;
     }
     result = tailmatch(self, substring, start, end, +1);
+    Py_DECREF(substring);
     if (result == -1)
         return NULL;
-    Py_DECREF(substring);
     return PyBool_FromLong(result);
 }
 

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


More information about the Python-checkins mailing list