]> git.sur5r.net Git - openldap/commitdiff
Fix database search loop conditions
authorHoward Chu <hyc@openldap.org>
Thu, 17 Apr 2003 04:55:39 +0000 (04:55 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 17 Apr 2003 04:55:39 +0000 (04:55 +0000)
servers/slapd/back-bdb/dbcache.c

index 6d4456bde6b229eb28bfddd07c8aeb93c9aca5d1..3eddc2ab1a29537deb82b9c8d4abdc8809b381c7 100644 (file)
@@ -62,7 +62,7 @@ bdb_db_cache(
 
        *dbout = NULL;
 
-       for( i=BDB_NDB; bdb->bi_databases[i]; i++ ) {
+       for( i=BDB_NDB; i < BDB_INDICES && bdb->bi_databases[i]; i++ ) {
                if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
                        *dbout = bdb->bi_databases[i]->bdi_db;
                        return 0;
@@ -86,7 +86,7 @@ bdb_db_cache(
        if (rc) return rc;
 
        /* check again! may have been added by another thread */
-       for( i=BDB_NDB; bdb->bi_databases[i]; i++ ) {
+       for( i=BDB_NDB; i < BDB_INDICES && bdb->bi_databases[i]; i++ ) {
                if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
                        *dbout = bdb->bi_databases[i]->bdi_db;
                        LOCK_PUT( bdb->bi_dbenv, &lock);
@@ -152,7 +152,6 @@ bdb_db_cache(
                return rc;
        }
 
-       bdb->bi_databases[i+1] = NULL;
        bdb->bi_databases[i] = db;
        bdb->bi_ndatabases = i+1;