From 68daf5bee9cb569aad8225b288de0805138cf5a2 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 29 Dec 2001 05:44:37 +0000 Subject: [PATCH] Misc cleanup --- servers/slapd/back-bdb/dn2id.c | 8 +++----- servers/slapd/back-bdb/search.c | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 4fca067aaf..1f5969e3ff 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -606,7 +606,7 @@ int bdb_fix_dn( o = bdb_find_id_node(id, bdb->bi_tree); rlen = be->be_suffix[0]->bv_len + 1; nrlen = be->be_nsuffix[0]->bv_len + 1; - for (n = o; n; n=n->i_parent) { + for (n = o; n && n->i_parent; n=n->i_parent) { rlen += n->i_rdn->rdn.bv_len + 1; nrlen += n->i_rdn->nrdn.bv_len + 1; } @@ -616,7 +616,7 @@ int bdb_fix_dn( e->e_nname.bv_val = e->e_name.bv_val + rlen; ptr = e->e_name.bv_val; nptr = e->e_nname.bv_val; - for (n = o; n; n=n->i_parent) { + for (n = o; n && n->i_parent; n=n->i_parent) { ptr = slap_strcopy(ptr, n->i_rdn->rdn.bv_val); *ptr++ = ','; nptr = slap_strcopy(nptr, n->i_rdn->nrdn.bv_val); @@ -624,8 +624,6 @@ int bdb_fix_dn( } ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr); - ptr--; - nptr--; strcpy(ptr, be->be_suffix[0]->bv_val); strcpy(nptr, be->be_nsuffix[0]->bv_val); @@ -665,7 +663,7 @@ bdb_dn2id_add( d->rdn.bv_val -= (long)d; d->nrdn.bv_val -= (long)d; - if (pdn) { + if (pdn->bv_len) { bdb_dn2id(be, txn, pdn, &d->parent); } else { d->parent = 0; diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 6456432f55..df25630b8c 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -118,10 +118,10 @@ bdb_search( } send_ldap_result( conn, op, rc=LDAP_REFERRAL , - matched_dn->bv_val, text, refs, NULL ); + matched_dn ? matched_dn->bv_val : NULL, text, refs, NULL ); - ber_bvecfree( refs ); - ber_bvfree( matched_dn ); + if ( refs ) ber_bvecfree( refs ); + if ( matched_dn ) ber_bvfree( matched_dn ); return rc; } -- 2.39.5