|
From: Steffen R. <ste...@sy...> - 2001-07-11 00:32:16
|
Michael Str=F6der <mi...@st...> writes: > Anyone did notice the forwarded warning message by Stig about > possible memory leaks with OpenLDAP 2.0.x API? > Please glance over it: > http://www.geocrawler.com/archives/3/1568/2001/6/0/6036658/ I looked through it. The first issue (ldap_first_attribute) has changed from OpenLDAP 1.2 to 2.0.x so that the memory is *never* freed by the library. In 1.1 it was freed, when the last attribute was read. However, the current python-ldap code did never free the memory. IOW, there is a possible memory leak in error cases. The second issue (ldap_get_dn) has *not* changed between OpenLDAP 1.2 and 2.0.x, i.e. the same kind of memory leak exists for both API versions. The attached patch should fix both issues. The last "ber_free()" should be surrounded by some #ifdef OPENLDAP_2_0_X conditional... I scanned through the documentation and did not notice any further changes in memory handling, but then again, I did not really look too hard. *** python-ldap-1.10alpha3/Modules/message.c Mon Aug 14 18:37:37 2000 --- python-ldap-openldap-2/Modules/message.c Mon Jul 2 10:55:30 2001 *************** *** 78,84 **** --- 78,86 ---- if (valuelist =3D=3D NULL) { Py_DECREF(attrdict); Py_DECREF(result); + ber_free(ber, 0); ldap_msgfree( m ); + ldap_memfree(attr); return NULL; } =20=20 *************** *** 95,101 **** --- 97,105 ---- Py_DECREF(result); Py_DECREF(valuestr); Py_DECREF(valuelist); + ber_free(ber, 0); ldap_msgfree( m ); + ldap_memfree(attr); return NULL; } Py_DECREF(valuestr); *************** *** 103,114 **** --- 107,121 ---- ldap_value_free_len(bvals); } Py_DECREF( valuelist ); + ldap_memfree(attr); } =20=20 entrytuple =3D Py_BuildValue("(sO)", dn, attrdict); + ldap_memfree(dn); Py_DECREF(attrdict); PyList_Append(result, entrytuple); Py_DECREF(entrytuple); + ber_free(ber, 0); } ldap_msgfree( m ); return result; /steffen --=20 ste...@sy... <> Gravity is a myth -- the Earth sucks! |