diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index fe0337fc46e..501921df8ee 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);