]> granicus.if.org Git - python/commitdiff
Fix memory leak in endswith
authorChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 18:41:06 +0000 (20:41 +0200)
committerChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 18:41:06 +0000 (20:41 +0200)
CID 1040368 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.

Objects/unicodeobject.c

index 5659c71ce8efd2efe629aaf8dba97ac6c4f34caa..30a925c3413664113ab8dd9b3555450c0aabe741 100644 (file)
@@ -12941,9 +12941,9 @@ unicode_endswith(PyObject *self,
         return NULL;
     }
     result = tailmatch(self, substring, start, end, +1);
+    Py_DECREF(substring);
     if (result == -1)
         return NULL;
-    Py_DECREF(substring);
     return PyBool_FromLong(result);
 }