From: Howard Chu Date: Sat, 29 Dec 2001 05:44:37 +0000 (+0000) Subject: Misc cleanup X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~420 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=68daf5bee9cb569aad8225b288de0805138cf5a2;p=openldap Misc cleanup --- 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; }