From: Howard Chu Date: Sun, 30 Dec 2001 00:14:45 +0000 (+0000) Subject: Cleanup, fix uninitialized vars X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~410 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7ffc723c40fe9ea7bef5fa458bf4a8289269a8b3;p=openldap Cleanup, fix uninitialized vars --- diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index 9743a0b2e2..7f94f7a2d0 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -328,7 +328,9 @@ bvarray_free( { int i; - for (i=0; a[i].bv_val; i++) - free(a[i].bv_val); - free(a); + if (a) { + for (i=0; a[i].bv_val; i++) + free(a[i].bv_val); + free(a); + } } diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 59b9b4cc33..558a528abf 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -609,9 +609,9 @@ UTF8SubstringsassertionNormalize( return nsa; err: - free( nsa->sa_final.bv_val ); - bvarray_free( nsa->sa_any ); - free( nsa->sa_initial.bv_val ); + if ( nsa->sa_final.bv_val ) free( nsa->sa_final.bv_val ); + if ( nsa->sa_any )bvarray_free( nsa->sa_any ); + if ( nsa->sa_initial.bv_val ) free( nsa->sa_initial.bv_val ); ch_free( nsa ); return NULL; } @@ -1111,9 +1111,12 @@ retry: if( idx >= left.bv_len ) { /* this shouldn't happen */ free( nav ); - ch_free( sub->sa_final.bv_val ); - bvarray_free( sub->sa_any ); - ch_free( sub->sa_initial.bv_val ); + if ( sub->sa_final.bv_val ) + ch_free( sub->sa_final.bv_val ); + if ( sub->sa_any ) + bvarray_free( sub->sa_any ); + if ( sub->sa_initial.bv_val ) + ch_free( sub->sa_initial.bv_val ); ch_free( sub ); return LDAP_OTHER; } @@ -1146,9 +1149,9 @@ retry: done: free( nav ); if( sub != NULL ) { - free( sub->sa_final.bv_val ); - bvarray_free( sub->sa_any ); - free( sub->sa_initial.bv_val ); + if ( sub->sa_final.bv_val ) free( sub->sa_final.bv_val ); + if ( sub->sa_any ) bvarray_free( sub->sa_any ); + if ( sub->sa_initial.bv_val ) free( sub->sa_initial.bv_val ); ch_free( sub ); } *matchp = match; @@ -1511,9 +1514,9 @@ static int caseExactIgnoreSubstringsFilter( } if( nkeys == 0 ) { - free( sa->sa_final.bv_val ); - bvarray_free( sa->sa_any ); - free( sa->sa_initial.bv_val ); + if ( sa->sa_final.bv_val ) free( sa->sa_final.bv_val ); + if ( sa->sa_any ) bvarray_free( sa->sa_any ); + if ( sa->sa_initial.bv_val ) free( sa->sa_initial.bv_val ); ch_free( sa ); *keysp = NULL; return LDAP_SUCCESS; @@ -1626,9 +1629,9 @@ static int caseExactIgnoreSubstringsFilter( ch_free( keys ); *keysp = NULL; } - free( sa->sa_final.bv_val ); - bvarray_free( sa->sa_any ); - free( sa->sa_initial.bv_val ); + if ( sa->sa_final.bv_val ) free( sa->sa_final.bv_val ); + if ( sa->sa_any ) bvarray_free( sa->sa_any ); + if ( sa->sa_initial.bv_val ) free( sa->sa_initial.bv_val ); ch_free( sa ); return LDAP_SUCCESS; diff --git a/servers/slapd/value.c b/servers/slapd/value.c index bc139e2f8e..e35ac85ca1 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -131,8 +131,8 @@ value_match( const char ** text ) { int rc; - struct berval nv1; - struct berval nv2; + struct berval nv1 = { 0, NULL }; + struct berval nv2 = { 0, NULL }; if( !mr->smr_match ) { return LDAP_INAPPROPRIATE_MATCHING; @@ -165,8 +165,8 @@ value_match( nv1.bv_val != NULL ? &nv1 : v1, nv2.bv_val != NULL ? &nv2 : v2 ); - free( nv1.bv_val ); - free( nv2.bv_val ); + if (nv1.bv_val ) free( nv1.bv_val ); + if (nv2.bv_val ) free( nv2.bv_val ); return rc; }