[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Memory leak when connect fails? (ITS#864)
Full_Name: Sam Varshavchik
Version: 1.2.11
OS: Linux.
URL:
Submission from: (NULL) (216.179.0.5)
I'm seeing a memory leak in a failed connection attempt.
Here's an example.
#include <lber.h>
#include <ldap.h>
int main()
{
LDAP *p;
for (;;)
{
p=ldap_init("127.0.0.1", 389);
if (!p) break;
printf("%d\n",
ldap_simple_bind_s(p, "dc=example.com",
"foobar"));
printf("unbind=%d\n",
ldap_unbind_s(p));
}
return (0);
}
If my server is completely down, I end up losing memory here quickly. If the
server is up, but the password is wrong, I'm not leaking any memory. If the
password is good, and bind succeeds, I'm not leaking memory either. Only when
the server is down, and the connect fails, do I have a large leak here.
When the server is down, ldap_simple_bind_s comes back with LDAP_SERVER_DOWN,
and ldap_unbind_s returns with LDAP_SUCCESS, but something gets leaked.
This will mess up a long-running LDAP client that's designed to be fault
tolerant,
that automatically reconnects to the server when it goes back up.