[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Sth about open-ldap client api memory leak.
The code below will cause about 300k meory leak when I run it 1000 times.
(I use oplenldap-stable-1.2.11) Why?
CODE:
if (( ld=ldap_init(_host,_port) ) == NULL)
{
cout<<"ldap init err: "<<errno<<endl;
}
if (ldap_simple_bind_s(ld,_usr,_usrpwd)!=LDAP_SUCCESS)
{
cout<<"ldap bind error:"<<ldap_err2string(ld->ld_errno)<<endl;
ldap_unbind(ld);
ld = NULL;
exit(1);
}
int rc=ldap_search_s(ld,
base,
scope,
filter,
a,
attronly,
&res);
if (rc != LDAP_SUCCESS)
{
cout<<"ldap search base:"<<base<<" filter:"<<filter
<<" error:"<<ldap_err2string(ld->ld_errno)<<endl;
if (ld) ldap_unbind(ld);
exit(1);
}
if(!res)
{
ldap_msgfree(res);
res = NULL;
}
if (ld) ldap_unbind(ld);