bonsai
bonsai copied to clipboard
native memleak in `ldap-xplat.c` (`ldap_init_thread_func`)
In ldap-xplat.c#L714 you allocate LDAP
.
- before
ldap_initialize
call just nullLDAP*
:
data->ld = NULL;
-
ldap_set_option
also calls can return other thanLDAP_SUCCESS
result, so we need to control this (for example):
...
rc = ldap_set_option(data->ld, LDAP_OPT_REFERRALS, ref_opt);
if (rc != LDAP_SUCCESS) {
data->retval = rc;
goto end;
}
...
- and finally at the
end
label we need to freeLDAP
struct if we have problems (and allocate it):
end:
// added:
if(data->retval != LDAP_SUCCESS){
ldap_destroy(data->ld);
data->ld = NULL;
}