diff options
author | Barry Warsaw <barry@python.org> | 1999-01-28 18:49:12 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1999-01-28 18:49:12 (GMT) |
commit | fa77e09dd006c9852d636481af6c6199b2d7b5aa (patch) | |
tree | 41eccd710cbe367b7219dae43247a7a80879e174 /Python | |
parent | c9bda41a210ed2235c1ba47dda8875696eda3850 (diff) | |
download | cpython-fa77e09dd006c9852d636481af6c6199b2d7b5aa.zip cpython-fa77e09dd006c9852d636481af6c6199b2d7b5aa.tar.gz cpython-fa77e09dd006c9852d636481af6c6199b2d7b5aa.tar.bz2 |
builtin_map(): A better fix for the previous leak plug (remember
PyList_Append steals a reference even if it fails).
builtin_filter(): Had the same leak problem as builtin_map().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 1929ae9..b0d0648 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -232,8 +232,10 @@ builtin_filter(self, args) goto Fail_1; } else { + int status = PyList_Append(result, item); j++; - if (PyList_Append(result, item) < 0) + Py_DECREF(item); + if (status < 0) goto Fail_1; } } else { @@ -901,9 +903,10 @@ builtin_map(self, args) goto Fail_1; } if (i >= len) { - if (PyList_Append(result, value) < 0) - goto Fail_1; + int status = PyList_Append(result, value); Py_DECREF(value); + if (status < 0) + goto Fail_1; } else { if (PyList_SetItem(result, i, value) < 0) |