summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/grpmodule.c2
-rw-r--r--Modules/pwdmodule.c1
3 files changed, 4 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 8cc76a2..b98a368 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -108,6 +108,8 @@ Installation
Extension Modules
-----------------
+- Issue #4873: Fix resource leaks in error cases of pwd and grp.
+
- Issue #6093: Fix off-by-one error in locale.strxfrm.
- The _functools and _locale modules are now built into the libpython shared
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index e642731..0dcef06 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -79,7 +79,6 @@ mkgrent(struct group *p)
if (PyErr_Occurred()) {
Py_DECREF(v);
- Py_DECREF(w);
return NULL;
}
@@ -145,6 +144,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 5802818..1547cdf 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -175,6 +175,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);