There is a memory leak in the last for loop of the ads_default_ou_string(...) function in ldap.c. The code segment that has the leak is c&p below. http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/branches/SAMBA_3_0_23/source/libads/ldap.c?rev=19528&view=markup <Original Code> ret = SMB_STRDUP(wkn_dn_exp[0]); for (i=1; i < new_ln; i++) { char *s; asprintf(&s, "%s,%s", ret, wkn_dn_exp[i]); ret = SMB_STRDUP(s); free(s); } <End Original code> The problem occurs when "new_ln" is greater then 1. In the for body, the string pointed to by "ret" before the "ret = SMB_STRDUP(s);" call is actually lost before any attempt to release it back to the system. The string pointed to by "ret" should be freed before "ret = SMB_STRDUP(s)". The following code segment fixes the leak. <Fix Code> ret = SMB_STRDUP(wkn_dn_exp[0]); for (i=1; i < new_ln; i++) { char *s; asprintf(&s, "%s,%s", ret, wkn_dn_exp[i]); + SAFE_FREE(ret); ret = SMB_STRDUP(s); free(s); } <End Fix Code>
Rev. 19646 has that fixed. Thanks for the report.