]> git.sur5r.net Git - openldap/commitdiff
Plug a few memory leaks
authorHallvard Furuseth <hallvard@openldap.org>
Sun, 4 Apr 1999 05:04:48 +0000 (05:04 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Sun, 4 Apr 1999 05:04:48 +0000 (05:04 +0000)
libraries/libldap/modrdn.c
libraries/libldap/request.c

index 9028e33fc0469ad77dda27957ccf473708b10981..d148ab552b2b6e9f38bd6bb13015a25736b67a33 100644 (file)
@@ -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,
index 5b8ecc8c5e45a0d4028f7b2f7a8288a95f348e85..ed56a0563bbb61bf2ee7f590336660e5f7046c34 100644 (file)
@@ -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 );
                }