diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 75dd12b1b2..77c92d220a 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -82,7 +82,6 @@ ldbm_back_add( if ( (pdn = dn_parent( be, dn )) != NULL ) { char *matched; /* no parent */ - matched = NULL; /* get entry with reader lock */ if ( (p = dn2entry_r( be, pdn, &matched )) == NULL ) { @@ -90,6 +89,7 @@ ldbm_back_add( 0, 0 ); send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" ); + if ( matched != NULL ) { free( matched ); } @@ -97,9 +97,6 @@ ldbm_back_add( rc = -1; goto return_results; } - if ( matched != NULL ) { - free( matched ); - } if ( ! access_allowed( be, conn, op, p, "children", NULL, op->o_dn, ACL_WRITE ) ) { diff --git a/servers/slapd/back-ldbm/alias.c b/servers/slapd/back-ldbm/alias.c index 5285087078..92eca6c6df 100644 --- a/servers/slapd/back-ldbm/alias.c +++ b/servers/slapd/back-ldbm/alias.c @@ -112,7 +112,7 @@ char *derefDN ( Backend *be, ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char *matched = NULL; + char *matched; char *newDN = NULL; int depth; Entry *eMatched; @@ -135,7 +135,7 @@ char *derefDN ( Backend *be, /* free reader lock */ cache_return_entry_r(&li->li_cache, eMatched); - if (*matched) { + if ((matched != NULL) && *matched) { char *submatch; /* @@ -155,6 +155,7 @@ char *derefDN ( Backend *be, if ((eNew = derefAlias_r( be, conn, op, eMatched )) == NULL) { free (matched); + matched = NULL; free (newDN); newDN = NULL; free (remainder); @@ -169,6 +170,7 @@ char *derefDN ( Backend *be, free (newDN); newDN = NULL; free (matched); + matched = NULL; free (remainder); break; } @@ -178,13 +180,13 @@ char *derefDN ( Backend *be, * the new dn together */ free (newDN); - free (matched); - newDN = ch_malloc (strlen(eMatched->e_dn) + rlen + 1); strcpy (newDN, remainder); strcat (newDN, eMatched->e_dn); Debug( LDAP_DEBUG_TRACE, "<= expanded to %s\n", newDN, 0, 0 ); + free (matched); + matched = NULL; free (remainder); /* free reader lock */ @@ -234,7 +236,7 @@ char *derefDN ( Backend *be, } Debug( LDAP_DEBUG_TRACE, "<= returning deref DN of %s\n", newDN, 0, 0 ); - free(matched); + if (matched != NULL) free(matched); return newDN; } diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 591e488c9c..cb59ab0349 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -126,7 +126,7 @@ ldbm_back_bind( Entry *e; Attribute *a; int rc; - char *matched = NULL; + char *matched; #ifdef HAVE_KERBEROS char krbname[MAX_K_NAME_SZ + 1]; AUTH_DAT ad; diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index d17c5da88a..29f654751c 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -29,6 +29,8 @@ ldbm_back_compare( /* get entry with reader lock */ if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) { send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" ); + + if(matched == NULL) free(matched); return( 1 ); } diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 7e0008ba80..64723229f9 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -20,7 +20,7 @@ ldbm_back_delete( ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char *matched = NULL; + char *matched; char *pdn = NULL; Entry *e, *p; @@ -66,7 +66,6 @@ ldbm_back_delete( /* XXX delete from parent's id2children entry XXX */ pdn = dn_parent( be, dn ); - matched = NULL; p = dn2entry_r( be, pdn, &matched ); if ( id2children_remove( be, p, e ) != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "","" ); @@ -93,9 +92,11 @@ ldbm_back_delete( /* free entry and writer lock */ cache_return_entry_w( &li->li_cache, e ); - if ( p ) + if ( p != NULL ) cache_return_entry_r( &li->li_cache, p ); + if ( matched != NULL ) free(matched); + send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); return( 0 ); @@ -104,8 +105,10 @@ error_return:; /* free entry and writer lock */ cache_return_entry_w( &li->li_cache, e ); - if( p ) + if( p != NULL ) cache_return_entry_r( &li->li_cache, p ); + if ( matched != NULL ) free(matched); + return( -1 ); } diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 593107cc2c..ae0f62d8dd 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -166,18 +166,19 @@ dn2entry( { struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID id; - Entry *e; + Entry *e = NULL; char *pdn; Debug(LDAP_DEBUG_TRACE, "dn2entry_%s: dn: %s\n", rw ? "w" : "r", dn, 0); + *matched = NULL; + if ( (id = dn2id( be, dn )) != NOID && (e = id2entry( be, id, rw )) != NULL ) { return( e ); } - *matched = NULL; /* stop when we get to the suffix */ if ( be_issuffix( be, dn ) ) { @@ -199,19 +200,6 @@ dn2entry( return( NULL ); } -#if 0 - if (e->e_state == ENTRY_STATE_DELETED) - continue; - - if (strcmp(dn, e->e_dn) != 0) - continue; - - /* return locked entry entry */ - return(e); - } -} -#endif - Entry * dn2entry_r( Backend *be, diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c index 7def923a4d..a889041c25 100644 --- a/servers/slapd/back-ldbm/group.c +++ b/servers/slapd/back-ldbm/group.c @@ -45,7 +45,8 @@ ldbm_back_group( free(matched); return( 1 ); } - Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %s\n", bdn, (matched ? matched : ""), 0 ); + + Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s\n", bdn, 0, 0 ); /* check for deleted */ diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 7b0d141d0f..2f74c108f1 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -25,7 +25,7 @@ ldbm_back_modify( ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - char *matched = NULL; + char *matched; Entry *e; int i, err; LDAPMod *mod; diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 4b25fe66cd..65d78af635 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -49,7 +49,7 @@ ldbm_back_search( ID id; Entry *e; Attribute *ref; - char *matched = NULL; + char *matched; int rmaxsize, nrefs; char *rbuf, *rcur, *r; int nentries = 0;