]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/filterindex.c
Mem context tweaks for bdb_dn2idl
[openldap] / servers / slapd / back-bdb / filterindex.c
index 3b0ed135a384a05dcf2522f1ff39188297e90e29..24b2cbe843c407fc2a012078d56455337711394a 100644 (file)
@@ -50,7 +50,7 @@ bdb_filter_candidates(
        ID *tmp,
        ID *stack )
 {
-       int rc = -1;
+       int rc = 0;
 #ifdef NEW_LOGGING
        LDAP_LOG ( INDEX, ENTRY, "=> bdb_filter_candidates\n", 0, 0, 0 );
 #else
@@ -59,7 +59,6 @@ bdb_filter_candidates(
 
        switch ( f->f_choice ) {
        case SLAPD_FILTER_COMPUTED:
-               rc = 0;
                break;
 
        case SLAPD_FILTER_DN_ONE:
@@ -68,7 +67,8 @@ bdb_filter_candidates(
 #else
                Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
 #endif
-               rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, ids );
+               rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, ids,
+                       op->o_tmpmemctx );
                if( rc == DB_NOTFOUND ) {
                        BDB_IDL_ZERO( ids );
                        rc = 0;
@@ -81,7 +81,8 @@ bdb_filter_candidates(
 #else
                Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
 #endif
-               rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids );
+               rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids,
+                       op->o_tmpmemctx );
                break;
 
        case LDAP_FILTER_PRESENT:
@@ -150,7 +151,6 @@ bdb_filter_candidates(
                { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
                BDB_IDL_ALL( bdb, ids );
                }
-               rc = 0;
                break;
 
        case LDAP_FILTER_AND:
@@ -180,6 +180,10 @@ bdb_filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n",
                        (unsigned long) f->f_choice, 0, 0 );
 #endif
+               /* Must not return NULL, otherwise extended filters break */
+               { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
+               BDB_IDL_ALL( bdb, ids );
+               }
        }
 
 #ifdef NEW_LOGGING
@@ -488,6 +492,7 @@ equality_candidates(
                if( rc == DB_NOTFOUND ) {
                        BDB_IDL_ZERO( ids );
                        rc = 0;
+                       break;
                } else if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG ( INDEX, RESULTS,