Issue 864 - Memory leak when connect fails?
Summary: Memory leak when connect fails?
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-10-29 05:19 UTC by mrsam@courier-mta.com
Modified: 2014-08-01 21:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description mrsam@courier-mta.com 2000-10-29 05:19:32 UTC
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.

Comment 1 Kurt Zeilenga 2001-01-15 11:49:33 UTC
changed notes
changed state Open to Closed
Comment 2 OpenLDAP project 2014-08-01 21:06:12 UTC
1.2 issue