]> git.sur5r.net Git - openldap/commitdiff
Plug memory leaks - free() controls in LDAP*
authorHallvard Furuseth <hallvard@openldap.org>
Mon, 1 Aug 2005 03:51:53 +0000 (03:51 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Mon, 1 Aug 2005 03:51:53 +0000 (03:51 +0000)
libraries/libldap/options.c
libraries/libldap/unbind.c

index 6f678680cf0679c7da15bf55752e89ecd89a56da..e8106c5e7d0d872c34b094ab7f0de64191ebc909 100644 (file)
@@ -388,7 +388,8 @@ ldap_set_option(
                        LDAPControl *const *controls =
                                (LDAPControl *const *) invalue;
 
-                       ldap_controls_free( lo->ldo_sctrls );
+                       if( lo->ldo_sctrls )
+                               ldap_controls_free( lo->ldo_sctrls );
 
                        if( controls == NULL || *controls == NULL ) {
                                lo->ldo_sctrls = NULL;
@@ -407,7 +408,8 @@ ldap_set_option(
                        LDAPControl *const *controls =
                                (LDAPControl *const *) invalue;
 
-                       ldap_controls_free( lo->ldo_cctrls );
+                       if( lo->ldo_cctrls )
+                               ldap_controls_free( lo->ldo_cctrls );
 
                        if( controls == NULL || *controls == NULL ) {
                                lo->ldo_cctrls = NULL;
index 0158edf5b479ca9444e6a39a69145c030dcd0e5f..c58d7a2a0a4df75f0b68ade6df1b8642f81ce53d 100644 (file)
@@ -172,6 +172,16 @@ ldap_ld_free(
        }
 #endif
 
+       if ( ld->ld_options.ldo_sctrls != NULL ) {
+               ldap_controls_free( ld->ld_options.ldo_sctrls );
+               ld->ld_options.ldo_sctrls = NULL;
+       }
+
+       if ( ld->ld_options.ldo_cctrls != NULL ) {
+               ldap_controls_free( ld->ld_options.ldo_cctrls );
+               ld->ld_options.ldo_cctrls = NULL;
+       }
+
        ber_sockbuf_free( ld->ld_sb );   
    
 #ifdef LDAP_R_COMPILE