aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-01-18 16:06:29 +0100
committerYang Tse <yangsita@gmail.com>2012-01-18 16:06:29 +0100
commit2cafb0e97c288d2e942a50e964e1604c692871db (patch)
treea2754926563df6b62a8821d3155ce638322fc5f0 /lib
parent6ea7acf5a96786f7514be4fbce174cdc8bedfdd1 (diff)
OpenLDAP: fix LDAP connection phase memory leak
bug: http://curl.haxx.se/bug/view.cgi?id=3474308
Diffstat (limited to 'lib')
-rw-r--r--lib/openldap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/openldap.c b/lib/openldap.c
index e5a3369a1..a26ff2e15 100644
--- a/lib/openldap.c
+++ b/lib/openldap.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
- * Copyright (C) 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -336,7 +336,10 @@ retry:
int proto;
ldap_get_option(li->ld, LDAP_OPT_PROTOCOL_VERSION, &proto);
if(proto == LDAP_VERSION3) {
- ldap_memfree(info);
+ if(info) {
+ ldap_memfree(info);
+ info = NULL;
+ }
proto = LDAP_VERSION2;
ldap_set_option(li->ld, LDAP_OPT_PROTOCOL_VERSION, &proto);
li->didbind = FALSE;
@@ -347,8 +350,13 @@ retry:
if(err) {
failf(data, "LDAP remote: bind failed %s %s", ldap_err2string(rc),
info ? info : "");
+ if(info)
+ ldap_memfree(info);
return CURLE_LOGIN_DENIED;
}
+
+ if(info)
+ ldap_memfree(info);
conn->recv[FIRSTSOCKET] = ldap_recv;
*done = TRUE;
return CURLE_OK;