]> granicus.if.org Git - python/commitdiff
builtin_map(): Nailed memory leak. PyList_Append() borrows a
authorBarry Warsaw <barry@python.org>
Thu, 28 Jan 1999 04:21:35 +0000 (04:21 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 28 Jan 1999 04:21:35 +0000 (04:21 +0000)
reference, so you have to DECREF the appended value.  This was a fun
one!

Python/bltinmodule.c

index df6b98b42c401c572633f4bd1c16f33d969e888c..1929ae92ba7f3ca375f15f2105a97f971a12239e 100644 (file)
@@ -903,6 +903,7 @@ builtin_map(self, args)
                if (i >= len) {
                        if (PyList_Append(result, value) < 0)
                                goto Fail_1;
+                       Py_DECREF(value);
                }
                else {
                        if (PyList_SetItem(result, i, value) < 0)