From: Barry Warsaw Date: Fri, 18 Aug 2000 05:09:50 +0000 (+0000) Subject: pattern_findall(): Plug small memory leak discovered by Insure. X-Git-Tag: v2.0b1~375 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=152fbe88e9fd661c195b2374a0d229998e18e8dc;p=thirdparty%2FPython%2Fcpython.git pattern_findall(): Plug small memory leak discovered by Insure. PyList_Append() always incref's the inserted item. Be sure to decref it regardless of whether the append succeeds or fails. --- diff --git a/Modules/_sre.c b/Modules/_sre.c index 29e92ac574f9..3b78fb97e803 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1698,10 +1698,10 @@ pattern_findall(PatternObject* self, PyObject* args) break; } - if (PyList_Append(list, item) < 0) { - Py_DECREF(item); + status = PyList_Append(list, item); + Py_DECREF(item); + if (status < 0) goto error; - } if (state.ptr == state.start) state.start = (void*) ((char*) state.ptr + state.charsize);