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.
This commit is contained in:
Christian Heimes 2013-06-29 21:17:34 +02:00
parent 22ed7fe906
commit ea71a525c3
1 changed files with 12 additions and 4 deletions

View File

@ -12248,10 +12248,14 @@ unicode_rfind(PyObject *self, PyObject *args)
&start, &end)) &start, &end))
return NULL; return NULL;
if (PyUnicode_READY(self) == -1) if (PyUnicode_READY(self) == -1) {
Py_DECREF(substring);
return NULL; return NULL;
if (PyUnicode_READY(substring) == -1) }
if (PyUnicode_READY(substring) == -1) {
Py_DECREF(substring);
return NULL; return NULL;
}
result = any_find_slice(-1, self, substring, start, end); result = any_find_slice(-1, self, substring, start, end);
@ -12280,10 +12284,14 @@ unicode_rindex(PyObject *self, PyObject *args)
&start, &end)) &start, &end))
return NULL; return NULL;
if (PyUnicode_READY(self) == -1) if (PyUnicode_READY(self) == -1) {
Py_DECREF(substring);
return NULL; return NULL;
if (PyUnicode_READY(substring) == -1) }
if (PyUnicode_READY(substring) == -1) {
Py_DECREF(substring);
return NULL; return NULL;
}
result = any_find_slice(-1, self, substring, start, end); result = any_find_slice(-1, self, substring, start, end);