From: Howard Chu Date: Fri, 8 Feb 2008 06:32:41 +0000 (+0000) Subject: ITS#5332 someone else may free the entry as soon as we unlock it X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~190 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a3262ff2399e149dc04040b2803cd1fae4fbe5db;p=openldap ITS#5332 someone else may free the entry as soon as we unlock it --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 3156667d40..9c0ad33950 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -251,15 +251,17 @@ bdb_cache_return_entry_rw( struct bdb_info *bdb, Entry *e, EntryInfo *ei; int free = 0; - bdb_cache_entry_db_unlock( bdb, lock ); ei = e->e_private; - bdb_cache_entryinfo_lock( ei ); - if ( ei->bei_state & CACHE_ENTRY_NOT_CACHED ) { - ei->bei_e = NULL; - ei->bei_state ^= CACHE_ENTRY_NOT_CACHED; - free = 1; + bdb_cache_entry_db_unlock( bdb, lock ); + if ( ei ) { + bdb_cache_entryinfo_lock( ei ); + if ( ei->bei_state & CACHE_ENTRY_NOT_CACHED ) { + ei->bei_e = NULL; + ei->bei_state ^= CACHE_ENTRY_NOT_CACHED; + free = 1; + } + bdb_cache_entryinfo_unlock( ei ); } - bdb_cache_entryinfo_unlock( ei ); if ( free ) { e->e_private = NULL; bdb_entry_return( e );