[python-ldap] Suspected memory leak in Modules/errors.c:LDAPerr

David Malcolm dmalcolm at redhat.com
Wed Dec 7 22:41:36 CET 2011

I'm running an experimental static analysis tool [1] over python-ldap,
and it discovered what looks like a real reference leak:

Modules/errors.c: In function ‘LDAPerr’,
if it executes this code:
		    Py_BuildValue("{s:i}", "errnum", errnum));

then Py_BuildValue returns a new dictionary with refcount 1, owned by
the caller; PyErr_SetObject adds a new ref; the first ref is leaked;
hence the dictionary is leaked every time 

HTML version of the above attached.

Having said that, it looks like this branch is only followed when
receiving an unexpected error ID.

Hope this is helpful

[1] http://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20111207/ab13ca33/attachment.html>

More information about the python-ldap mailing list