From 9524dd362fb70d9d5bfdd75694c0b6a8c17fa4f1 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 4 Dec 2017 11:32:11 +0100 Subject: [PATCH] Fix memory leak in whoami_s l_ldap_whoami_s() did not free the berval struct from ldap_whoami_s(). https://github.com/python-ldap/python-ldap/pull/84 Closes: https://github.com/python-ldap/python-ldap/issues/80 Signed-off-by: Christian Heimes --- CHANGES | 1 + Modules/LDAPObject.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index b64c263..dfe4e4d 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,7 @@ Modules/ * Fix multiple ref leaks in error-handling code * Fix reference leak in result4 * Fix several compiler warnings +* Fix memory leak in whoami and, thanks to Michael Ströder: * removed unused code schema.c * moved code from version.c to ldapmodule.c diff --git a/Modules/LDAPObject.c b/Modules/LDAPObject.c index 8c90a65..815fe42 100644 --- a/Modules/LDAPObject.c +++ b/Modules/LDAPObject.c @@ -1227,10 +1227,13 @@ l_ldap_whoami_s( LDAPObject* self, PyObject* args ) LDAPControl_List_DEL( server_ldcs ); LDAPControl_List_DEL( client_ldcs ); - if ( ldaperror!=LDAP_SUCCESS ) + if ( ldaperror!=LDAP_SUCCESS ) { + ber_bvfree(bvalue); return LDAPerror( self->ldap, "ldap_whoami_s" ); + } result = LDAPberval_to_unicode_object(bvalue); + ber_bvfree(bvalue); return result; }