Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 9991:ddbbed8cb830 legacy-trunk
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().
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Thu, 28 Jan 1999 18:49:12 +0000 |
| parents | dcbe72a0b392 |
| children | 94125a1343d8 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Thu Jan 28 17:46:50 1999 +0000 +++ b/Python/bltinmodule.c Thu Jan 28 18:49:12 1999 +0000 @@ -232,8 +232,10 @@ 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 @@ goto Fail_1; } if (i >= len) { - if (PyList_Append(result, value) < 0) + int status = PyList_Append(result, value); + Py_DECREF(value); + if (status < 0) goto Fail_1; - Py_DECREF(value); } else { if (PyList_SetItem(result, i, value) < 0)
