]> granicus.if.org Git - python/commitdiff
Merged revisions 73016 via svnmerge from
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 29 May 2009 16:01:34 +0000 (16:01 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 29 May 2009 16:01:34 +0000 (16:01 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73016 | martin.v.loewis | 2009-05-29 17:58:08 +0200 (Fr, 29 Mai 2009) | 2 lines

  Issue #4873: Fix resource leaks in error cases of pwd and grp.
........

Misc/NEWS
Modules/grpmodule.c
Modules/pwdmodule.c

index 8cc76a258f03d7283bce59dd966baf1bcc0c8289..b98a36884846589bd79ca7945786645cffffc186 100644 (file)
--- 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
index e642731f834027b9351892704413ace67a9d3182..0dcef06c046161a6b9cc04715b31f9c16fe88161 100644 (file)
@@ -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);
index 5802818149ac5589c0e40bab29b91c7934005e35..1547cdf27aabb613221ea8141a5898a09772b951 100644 (file)
@@ -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);