]> granicus.if.org Git - python/commitdiff
pattern_findall(): Plug small memory leak discovered by Insure.
authorBarry Warsaw <barry@python.org>
Fri, 18 Aug 2000 05:09:50 +0000 (05:09 +0000)
committerBarry Warsaw <barry@python.org>
Fri, 18 Aug 2000 05:09:50 +0000 (05:09 +0000)
PyList_Append() always incref's the inserted item.  Be sure to decref
it regardless of whether the append succeeds or fails.

Modules/_sre.c

index 29e92ac574f9caea60df8bcec14d3748ba9daa66..3b78fb97e8030d6eb70f64231061ecc60ae35fb0 100644 (file)
@@ -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);