From 95d472aa9830a031821f2c6274aff38aa4eb0990 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 7 Oct 2008 22:16:15 +0000 Subject: [PATCH] ITS#5729 check for NULL bei_parent --- servers/slapd/back-bdb/dn2id.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index ec1d70c69a..a358fe0d66 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -613,10 +613,12 @@ hdb_dn2id_add( tmp[1] = eip->bei_id; *ptr = DN_ONE_PREFIX; bdb_idl_cache_add_id( bdb, db, &key, e->e_id ); - *ptr = DN_SUBTREE_PREFIX; - for (; eip && eip->bei_parent->bei_id; eip = eip->bei_parent) { - tmp[1] = eip->bei_id; - bdb_idl_cache_add_id( bdb, db, &key, e->e_id ); + if ( eip->bei_parent ) { + *ptr = DN_SUBTREE_PREFIX; + for (; eip && eip->bei_parent->bei_id; eip = eip->bei_parent) { + tmp[1] = eip->bei_id; + bdb_idl_cache_add_id( bdb, db, &key, e->e_id ); + } } } @@ -710,10 +712,12 @@ func_leave: tmp[1] = eip->bei_id; *ptr = DN_ONE_PREFIX; bdb_idl_cache_del_id( bdb, db, &key, e->e_id ); - *ptr = DN_SUBTREE_PREFIX; - for (; eip && eip->bei_parent->bei_id; eip = eip->bei_parent) { - tmp[1] = eip->bei_id; - bdb_idl_cache_del_id( bdb, db, &key, e->e_id ); + if ( eip ->bei_parent ) { + *ptr = DN_SUBTREE_PREFIX; + for (; eip && eip->bei_parent->bei_id; eip = eip->bei_parent) { + tmp[1] = eip->bei_id; + bdb_idl_cache_del_id( bdb, db, &key, e->e_id ); + } } } Debug( LDAP_DEBUG_TRACE, "<= hdb_dn2id_delete 0x%lx: %d\n", e->e_id, rc, 0 ); -- 2.39.5