From 8cbd5ecc13c253fcd9eb5191aa2e9a32f0298b4d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 31 Mar 2006 10:45:23 +0000 Subject: [PATCH] Cleanup --- servers/slapd/back-monitor/init.c | 2 +- servers/slapd/component.c | 12 ++---------- servers/slapd/overlays/syncprov.c | 3 --- servers/slapd/sl_malloc.c | 3 +++ servers/slapd/value.c | 4 +++- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 5e3c1db925..249b364163 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -860,7 +860,7 @@ monitor_back_register_entry_attrs( done:; if ( rc ) { - if ( *atp ) { + if ( atp && *atp ) { attrs_free( *atp ); *atp = NULL; } diff --git a/servers/slapd/component.c b/servers/slapd/component.c index 3fe99d1dfd..0b6cb2d519 100644 --- a/servers/slapd/component.c +++ b/servers/slapd/component.c @@ -594,16 +594,8 @@ get_component_reference( return rc; } - if ( rc == LDAP_SUCCESS ) { - *cr = ca_comp_ref; - **cr = *ca_comp_ref; - - } else if ( op ) { - op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx ); - - } else { - free( ca_comp_ref ) ; - } + *cr = ca_comp_ref; + **cr = *ca_comp_ref; (*cr)->cr_string.bv_val = start; (*cr)->cr_string.bv_len = end - start + 1; diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index f697131834..916b2a2ae3 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1302,9 +1302,6 @@ syncprov_add_slog( Operation *op, struct berval *csn ) sl->sl_mincsn.bv_len = se->se_csn.bv_len; ch_free( se ); sl->sl_num--; - if ( !sl->sl_head ) { - sl->sl_tail = NULL; - } } ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); } diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index 17c9207c8f..32b45bc271 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -422,6 +422,9 @@ slap_sl_free(void *ptr, void *ctx) unsigned long diff; int i, inserted = 0; + if (!ptr) + return; + if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) { ber_memfree_x(ptr, NULL); } else if (sh->sh_stack && (char *)ptr + p[-1] == sh->sh_last) { diff --git a/servers/slapd/value.c b/servers/slapd/value.c index dbd30cff8f..4afb5e6401 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -75,7 +75,7 @@ value_add( } v2 = &(*vals)[n]; - for ( ; !BER_BVISNULL( addvals ); v2++, addvals++ ) { + for ( n = 0 ; n < nn; v2++, addvals++ ) { ber_dupbv( v2, addvals ); if ( BER_BVISNULL( v2 ) ) break; } @@ -718,6 +718,8 @@ ordered_value_add( next[ 0 ] != '}' || next - vals[i].bv_val > vals[i].bv_len ) { + ch_free( nnew ); + ch_free( new ); return -1; } if ( k > anum ) k = -1; -- 2.39.5