From: Christian Heimes Date: Sat, 29 Jun 2013 19:21:37 +0000 (+0200) Subject: Fix ref leak in error case of unicode index X-Git-Tag: v3.4.0a1~361 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d47a0456b1120fe15bf2996a7acfd0e3340c6c9a;p=thirdparty%2FPython%2Fcpython.git Fix ref leak in error case of unicode index CID 983319 (#1 of 2): 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 fe0337fc46e8..501921df8ee9 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -11180,10 +11180,14 @@ unicode_index(PyObject *self, PyObject *args) &start, &end)) return NULL; - if (PyUnicode_READY(self) == -1) + if (PyUnicode_READY(self) == -1) { + Py_DECREF(substring); return NULL; - if (PyUnicode_READY(substring) == -1) + } + if (PyUnicode_READY(substring) == -1) { + Py_DECREF(substring); return NULL; + } result = any_find_slice(1, self, substring, start, end);