From 305e49e17edd6870b52af547a6c6cbf613864d05 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sat, 29 Jun 2013 20:41:06 +0200 Subject: [PATCH] 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. --- Objects/unicodeobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5659c71ce8e..30a925c3413 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); }