]> granicus.if.org Git - python/commitdiff
Issue #4873: Fix resource leaks in error cases of pwd and grp.
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 29 May 2009 15:58:08 +0000 (15:58 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 29 May 2009 15:58:08 +0000 (15:58 +0000)
Misc/NEWS
Modules/grpmodule.c
Modules/pwdmodule.c

index a0547892d782f16fe1a86334759cda5a31613d98..7e53d2499c17d75562256f898885b34230927e66 100644 (file)
--- 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.
 
index e5b9f4708c67879bdaf21f5ea5e822940ee68541..ffb451e1744388bd7f82fb88f304617c7d4499c1 100644 (file)
@@ -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);
index 9e01f4875768fd957e7045a8d2c895875b1d8c76..a271c5a82ebc5267f566bb6c161963afebc0ef10 100644 (file)
@@ -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);