diff options
author | Christian Heimes <christian@cheimes.de> | 2013-06-29 19:17:34 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-06-29 19:17:34 (GMT) |
commit | ea71a525c34784d188252947f497ed251f9d4d5c (patch) | |
tree | 82f587fc683363688241a33b7456587a1e09de09 /Objects/unicodeobject.c | |
parent | 22ed7fe9064d3ba21abcb76fab78cf587783039b (diff) | |
download | cpython-ea71a525c34784d188252947f497ed251f9d4d5c.zip cpython-ea71a525c34784d188252947f497ed251f9d4d5c.tar.gz cpython-ea71a525c34784d188252947f497ed251f9d4d5c.tar.bz2 |
Fix ref leak in error case of unicode rindex and rfind
CID 983320: Resource leak (RESOURCE_LEAK)
CID 983321: Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 30a925c..fe0337f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -12248,10 +12248,14 @@ unicode_rfind(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); @@ -12280,10 +12284,14 @@ unicode_rindex(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); |