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 5659c71..30a925c 100644
--- 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);
}