]> git.sur5r.net Git - openldap/commitdiff
Plug some memory leaks
authorHallvard Furuseth <hallvard@openldap.org>
Sun, 27 Dec 1998 03:55:57 +0000 (03:55 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Sun, 27 Dec 1998 03:55:57 +0000 (03:55 +0000)
servers/slapd/add.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/entry.c
servers/slapd/main.c

index 0f497a0d73767a709692c7fba0849d3947c2e1e2..6e9541b4ee38e4e1811c7e754f563f1415a4fc74 100644 (file)
@@ -71,6 +71,7 @@ do_add( Connection *conn, Operation *op )
                if ( ber_scanf( ber, "{a{V}}", &type, &vals ) == LBER_ERROR ) {
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
                            NULL, "decoding error" );
+                       free( dn );
                        entry_free( e );
                        return;
                }
@@ -80,6 +81,8 @@ do_add( Connection *conn, Operation *op )
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
                            NULL );
+                       free( type );
+                       free( dn );
                        entry_free( e );
                        return;
                }
@@ -98,7 +101,9 @@ do_add( Connection *conn, Operation *op )
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       if ( (be = select_backend( dn )) == NULL ) {
+       be = select_backend( dn );
+       free( dn );
+       if ( be == NULL ) {
                entry_free( e );
                send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
                    default_referral );
index 64723229f9dd7e1ce83dbadd14b4f25c363d958c..2072e2bfd8590fb0072408178ba6585f933249b5 100644 (file)
@@ -67,6 +67,7 @@ ldbm_back_delete(
        /* XXX delete from parent's id2children entry XXX */
        pdn = dn_parent( be, dn );
        p = dn2entry_r( be, pdn, &matched );
+       free( pdn );
        if ( id2children_remove( be, p, e ) != 0 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "","" );
                 goto error_return;
index 31d9551e17a64a7bc43a5dbfa88b0c294510fb2b..21a9d6ef7c44e0bd60aad7ae7ced7ea2db761f94 100644 (file)
@@ -30,7 +30,7 @@ filter_candidates(
     Filter     *f
 )
 {
-       IDList  *result;
+       IDList  *result, *tmp1, *tmp2;
 
        Debug( LDAP_DEBUG_TRACE, "=> filter_candidates\n", 0, 0, 0 );
 
@@ -78,8 +78,11 @@ filter_candidates(
 
        case LDAP_FILTER_NOT:
                Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 );
-               result = idl_notin( be, idl_allids( be ), filter_candidates( be,
-                   f->f_not ) );
+               tmp1 = idl_allids( be );
+               tmp2 = filter_candidates( be, f->f_not );
+               result = idl_notin( be, tmp1, tmp2 );
+               idl_free( tmp2 );
+               idl_free( tmp1 );
                break;
        }
 
index 726eaf675fb599d503f907d3799216b2b1a8f99f..67cc85833ec6445cc3ff83c174e4574833a25e5a 100644 (file)
@@ -47,8 +47,6 @@ str2entry( char       *s )
                s ? s : "NULL", 0, 0 );
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
-       /* initialize reader/writer lock */
-       entry_rdwr_init(e);
 
        /* check to see if there's an id included */
        next = s;
@@ -58,10 +56,14 @@ str2entry( char     *s )
                        Debug( LDAP_DEBUG_TRACE,
                            "<= str2entry NULL (missing newline after id)\n",
                            0, 0, 0 );
+                       free( e );
                        return( NULL );
                }
        }
 
+       /* initialize reader/writer lock */
+       entry_rdwr_init(e);
+
        /* dn + attributes */
        e->e_attrs = NULL;
        vals[0] = &bval;
@@ -101,6 +103,7 @@ str2entry( char     *s )
                    != 0 ) {
                        Debug( LDAP_DEBUG_TRACE,
                            "<= str2entry NULL (attr_merge)\n", 0, 0, 0 );
+                       entry_free( e );
                        return( NULL );
                }
                nvals++;
index e17b7c2f76f0fdc1b033517bdbfbc6e8bd0ad086..57ecbe44f285ffb901a7d4f752bca875ff09ae9f 100644 (file)
@@ -273,6 +273,7 @@ main( int argc, char **argv )
                                /* log and send error */
                                Debug( LDAP_DEBUG_ANY,
                                   "ber_get_int returns 0x%lx\n", tag, 0, 0 );
+                               ber_free( &ber, 1 );
                                return 1;
                        }