]> granicus.if.org Git - python/commitdiff
Fix ref leak in error case of unicode index
authorChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 19:21:37 +0000 (21:21 +0200)
committerChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 19:21:37 +0000 (21:21 +0200)
CID 983319 (#1 of 2): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.

Objects/unicodeobject.c

index fe0337fc46e8b83081c5309efbb4cec91b552901..501921df8ee932c3205daa9241c9af29aff8e7ab 100644 (file)
@@ -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);