From: Howard Chu Date: Mon, 31 Dec 2001 06:44:36 +0000 (+0000) Subject: Minor cleanup X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~396 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b92710e3a5f4ca512cb26ed0180c2ace9022183d;p=openldap Minor cleanup --- diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 6f70208469..5e33d6e1ce 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -840,7 +840,7 @@ parse_numericoid(const char **sp, int *code, const int flags) } } if (flags & LDAP_SCHEMA_SKIP) { - res = start; + res = (char *)start; } else { res = LDAP_MALLOC(len+1); if (!res) { @@ -1140,8 +1140,8 @@ void ldap_syntax_free( LDAPSyntax * syn ) { LDAP_FREE(syn->syn_oid); - LDAP_VFREE(syn->syn_names); - LDAP_FREE(syn->syn_desc); + if (syn->syn_names) LDAP_VFREE(syn->syn_names); + if (syn->syn_desc) LDAP_FREE(syn->syn_desc); free_extensions(syn->syn_extensions); LDAP_FREE(syn); } @@ -1281,9 +1281,9 @@ void ldap_matchingrule_free( LDAPMatchingRule * mr ) { LDAP_FREE(mr->mr_oid); - LDAP_VFREE(mr->mr_names); - LDAP_FREE(mr->mr_desc); - LDAP_FREE(mr->mr_syntax_oid); + if (mr->mr_names) LDAP_VFREE(mr->mr_names); + if (mr->mr_desc) LDAP_FREE(mr->mr_desc); + if (mr->mr_syntax_oid) LDAP_FREE(mr->mr_syntax_oid); free_extensions(mr->mr_extensions); LDAP_FREE(mr); } @@ -1475,9 +1475,9 @@ void ldap_matchingruleuse_free( LDAPMatchingRuleUse * mru ) { LDAP_FREE(mru->mru_oid); - LDAP_VFREE(mru->mru_names); - LDAP_FREE(mru->mru_desc); - LDAP_VFREE(mru->mru_applies_oids); + if (mru->mru_names) LDAP_VFREE(mru->mru_names); + if (mru->mru_desc) LDAP_FREE(mru->mru_desc); + if (mru->mru_applies_oids) LDAP_VFREE(mru->mru_applies_oids); free_extensions(mru->mru_extensions); LDAP_FREE(mru); } @@ -1668,13 +1668,13 @@ void ldap_attributetype_free(LDAPAttributeType * at) { LDAP_FREE(at->at_oid); - LDAP_VFREE(at->at_names); - LDAP_FREE(at->at_desc); - LDAP_FREE(at->at_sup_oid); - LDAP_FREE(at->at_equality_oid); - LDAP_FREE(at->at_ordering_oid); - LDAP_FREE(at->at_substr_oid); - LDAP_FREE(at->at_syntax_oid); + if (at->at_names) LDAP_VFREE(at->at_names); + if (at->at_desc) LDAP_FREE(at->at_desc); + if (at->at_sup_oid) LDAP_FREE(at->at_sup_oid); + if (at->at_equality_oid) LDAP_FREE(at->at_equality_oid); + if (at->at_ordering_oid) LDAP_FREE(at->at_ordering_oid); + if (at->at_substr_oid) LDAP_FREE(at->at_substr_oid); + if (at->at_syntax_oid) LDAP_FREE(at->at_syntax_oid); free_extensions(at->at_extensions); LDAP_FREE(at); } @@ -2048,11 +2048,11 @@ void ldap_objectclass_free(LDAPObjectClass * oc) { LDAP_FREE(oc->oc_oid); - LDAP_VFREE(oc->oc_names); - LDAP_FREE(oc->oc_desc); - LDAP_VFREE(oc->oc_sup_oids); - LDAP_VFREE(oc->oc_at_oids_must); - LDAP_VFREE(oc->oc_at_oids_may); + if (oc->oc_names) LDAP_VFREE(oc->oc_names); + if (oc->oc_desc) LDAP_FREE(oc->oc_desc); + if (oc->oc_sup_oids) LDAP_VFREE(oc->oc_sup_oids); + if (oc->oc_at_oids_must) LDAP_VFREE(oc->oc_at_oids_must); + if (oc->oc_at_oids_may) LDAP_VFREE(oc->oc_at_oids_may); free_extensions(oc->oc_extensions); LDAP_FREE(oc); } diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 8496342354..cc58efeda0 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -199,7 +199,7 @@ at_destroy( void ) for (a=attr_list; a; a=n) { n = a->sat_next; - ldap_memfree(a->sat_subtypes); + if (a->sat_subtypes) ldap_memfree(a->sat_subtypes); ad_destroy(a->sat_ad); ldap_pvt_thread_mutex_destroy(&a->sat_ad_mutex); ldap_attributetype_free((LDAPAttributeType *)a); diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 38bb9cfa86..f2746e63a9 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -97,8 +97,8 @@ ldbm_back_bind( NULL, NULL, NULL, NULL ); } - ber_bvecfree( refs ); - free( matched_dn ); + if ( refs ) ber_bvecfree( refs ); + if ( matched_dn ) free( matched_dn ); return( rc ); } diff --git a/servers/slapd/back-ldbm/referral.c b/servers/slapd/back-ldbm/referral.c index ed47d6b8b9..de4f04ec91 100644 --- a/servers/slapd/back-ldbm/referral.c +++ b/servers/slapd/back-ldbm/referral.c @@ -82,7 +82,7 @@ ldbm_back_referrals( NULL, NULL ); } - free( matched_dn ); + if ( matched_dn ) free( matched_dn ); return rc; } diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 52a28dddd6..6d6c034b26 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -510,7 +510,7 @@ done: if( candidates != NULL ) idl_free( candidates ); - ber_bvecfree( v2refs ); + if( v2refs ) ber_bvecfree( v2refs ); if( realbase.bv_val ) free( realbase.bv_val ); return rc; diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 3d52124824..4897cf9901 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -410,19 +410,19 @@ int backend_shutdown( Backend *be ) int backend_destroy(void) { int i; + BackendDB *bd; /* destroy each backend database */ - for( i = 0; i < nBackendDB; i++ ) { - if ( backendDB[i].bd_info->bi_db_destroy ) { - backendDB[i].bd_info->bi_db_destroy( - &backendDB[i] ); + for( i = 0, bd = backendDB; i < nBackendDB; i++, bd++ ) { + if ( bd->bd_info->bi_db_destroy ) { + bd->bd_info->bi_db_destroy( bd ); } - ber_bvecfree( backendDB[i].be_suffix ); - ber_bvecfree( backendDB[i].be_nsuffix ); - free( backendDB[i].be_rootdn.bv_val ); - free( backendDB[i].be_rootndn.bv_val ); - free( backendDB[i].be_rootpw.bv_val ); - acl_destroy( backendDB[i].be_acl, global_acl ); + ber_bvecfree( bd->be_suffix ); + ber_bvecfree( bd->be_nsuffix ); + if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val ); + if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val ); + if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val ); + acl_destroy( bd->be_acl, global_acl ); } free( backendDB ); diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 8422587bf3..3de3bb9013 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -28,7 +28,7 @@ const Entry slap_entry_root = { NOID, { 0, "" }, { 0, "" }, NULL, NULL }; int entry_destroy(void) { - free( ebuf ); + if ( ebuf ) free( ebuf ); ebuf = NULL; ecur = NULL; emaxsize = 0; diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index aad1a41a08..c39e4001d1 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -362,7 +362,7 @@ get_filter( break; } - free( ftmp.bv_val ); + if ( ftmp.bv_val ) free( ftmp.bv_val ); if ( err != LDAP_SUCCESS ) { if ( fstr->bv_val != NULL ) { diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 815da7d481..4565883db3 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -383,9 +383,9 @@ cleanup: free( pnewrdn.bv_val ); free( nnewrdn.bv_val ); - free( newSuperior.bv_val ); - free( pnewSuperior.bv_val ); - free( nnewSuperior.bv_val ); + if ( newSuperior.bv_val ) free( newSuperior.bv_val ); + if ( pnewSuperior.bv_val ) free( pnewSuperior.bv_val ); + if ( nnewSuperior.bv_val ) free( nnewSuperior.bv_val ); return rc; } diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 73cf9eac25..173cc82d4b 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -294,9 +294,9 @@ oc_destroy( void ) for (o=oc_list; o; o=n) { n = o->soc_next; - ldap_memfree(o->soc_sups); - ldap_memfree(o->soc_required); - ldap_memfree(o->soc_allowed); + if (o->soc_sups) ldap_memfree(o->soc_sups); + if (o->soc_required) ldap_memfree(o->soc_required); + if (o->soc_allowed) ldap_memfree(o->soc_allowed); ldap_objectclass_free((LDAPObjectClass *)o); } }