From 4f16d3b4ac92c93b2d8297cf62b1820603b67b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 29 May 2009 15:58:08 +0000 Subject: Issue #4873: Fix resource leaks in error cases of pwd and grp. --- Misc/NEWS | 2 ++ Modules/grpmodule.c | 2 +- Modules/pwdmodule.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index a054789..7e53d24 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1067,6 +1067,8 @@ C-API Extension Modules ----------------- +- Issue #4873: Fix resource leaks in error cases of pwd and grp. + - Issue #4751: For hashlib algorithms provided by OpenSSL, the Python GIL is now released during computation on data lengths >= 2048 bytes. diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index e5b9f47..ffb451e 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -76,7 +76,6 @@ mkgrent(struct group *p) if (PyErr_Occurred()) { Py_DECREF(v); - Py_DECREF(w); return NULL; } @@ -139,6 +138,7 @@ grp_getgrall(PyObject *self, PyObject *ignore) if (v == NULL || PyList_Append(d, v) != 0) { Py_XDECREF(v); Py_DECREF(d); + endgrent(); return NULL; } Py_DECREF(v); diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index 9e01f48..a271c5a 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -160,6 +160,7 @@ pwd_getpwall(PyObject *self) if (v == NULL || PyList_Append(d, v) != 0) { Py_XDECREF(v); Py_DECREF(d); + endpwent(); return NULL; } Py_DECREF(v); -- cgit v0.12