You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refcount error and file descriptor leaks in pwd, grp modules #49123
When investigating issue bpo-4859 I found that when pwd.getpwall()
and grp.getgrall() fail due to decoding errors, they leave open
file descriptors referring to the passwd and group files, since
they don't call the end*ent() functions in this case. Also, the
grp.* functions have a reference counting error when they fail in
this way - a debug build reports that an object's reference count
goes to -1. What I think happens is that in mkgrent(),
PyStructSequence_SET_ITEM steals the reference to "w", meaning
that the "Py_DECREF(w)" call shouldn't be made afterwards. The
attached diff fixes both of these problems, I think, and applies
to the 2.x and 3.x branches.
Activity
baikie commentedon Jan 7, 2009
When investigating issue bpo-4859 I found that when pwd.getpwall()
and grp.getgrall() fail due to decoding errors, they leave open
file descriptors referring to the passwd and group files, since
they don't call the end*ent() functions in this case. Also, the
grp.* functions have a reference counting error when they fail in
this way - a debug build reports that an object's reference count
goes to -1. What I think happens is that in mkgrent(),
PyStructSequence_SET_ITEM steals the reference to "w", meaning
that the "Py_DECREF(w)" call shouldn't be made afterwards. The
attached diff fixes both of these problems, I think, and applies
to the 2.x and 3.x branches.
loewis commentedon May 29, 2009
Thanks for the patch. Committed as r73016, r73017, r73018, r73019.