[New-bugs-announce] [issue4873] Refcount error and file descriptor leaks in pwd, grp modules

David Watson report at bugs.python.org
Wed Jan 7 23:30:46 CET 2009


New submission from David Watson <baikie at users.sourceforge.net>:

When investigating issue #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.

----------
components: Extension Modules
files: minor.diff
keywords: patch
messages: 79378
nosy: baikie
severity: normal
status: open
title: Refcount error and file descriptor leaks in pwd, grp modules
type: resource usage
Added file: http://bugs.python.org/file12639/minor.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4873>
_______________________________________


More information about the New-bugs-announce mailing list