From: Hallvard Furuseth Date: Sun, 4 Apr 1999 05:04:48 +0000 (+0000) Subject: Plug a few memory leaks X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~258 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=24fd4404d290693e107f73402d6b519e4c97b00f;p=openldap Plug a few memory leaks --- diff --git a/libraries/libldap/modrdn.c b/libraries/libldap/modrdn.c index 9028e33fc0..d148ab552b 100644 --- a/libraries/libldap/modrdn.c +++ b/libraries/libldap/modrdn.c @@ -49,8 +49,6 @@ ldap_rename2( LDAP *ld, int deleteoldrdn, char *newSuperior ) { - BerElement *ber; - /* * A modify rdn request looks like this: * ModifyRDNRequest ::= SEQUENCE { @@ -63,12 +61,13 @@ ldap_rename2( LDAP *ld, Debug( LDAP_DEBUG_TRACE, "ldap_rename2\n", 0, 0, 0 ); - /* create a message to send */ - if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); - } - if( newSuperior != NULL ) { + BerElement *ber; + + /* create a message to send */ + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { + return( -1 ); + } if ( ber_printf( ber, "{it{ssbts}}", ++ld->ld_msgid, diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 5b8ecc8c5e..ed56a0563b 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -90,6 +90,7 @@ ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, strdup( ld->ld_defhost )) == NULL )) { if (srv != NULL) free( srv ); + ber_free( ber, 1 ); ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); } @@ -101,6 +102,7 @@ ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, { if ( ld->ld_defhost != NULL ) free( srv->lsrv_host ); free( (char *)srv ); + ber_free( ber, 1 ); ld->ld_errno = LDAP_SERVER_DOWN; return( -1 ); } @@ -111,6 +113,7 @@ ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, ld->ld_defport, &ld->ld_host, 0 ) < 0 ) { ldap_ld_free( ld, 0 ); + ber_free( ber, 1 ); ld->ld_errno = LDAP_SERVER_DOWN; return( -1 ); }