From: Christian Heimes Date: Sat, 29 Jun 2013 18:41:06 +0000 (+0200) Subject: Fix memory leak in endswith X-Git-Tag: v3.4.0a1~366 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=305e49e17edd6870b52af547a6c6cbf613864d05;p=python 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. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5659c71ce8..30a925c341 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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); }