Skip to content

Commit

Permalink
Fix memory leak in whoami_s
Browse files Browse the repository at this point in the history
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 <cheimes@redhat.com>
  • Loading branch information
Christian Heimes authored and Petr Viktorin committed Dec 4, 2017
1 parent cd6f620 commit 9524dd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Modules/LDAPObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9524dd3

Please sign in to comment.