From: Jong Hyuk Choi Date: Thu, 23 Sep 2004 19:23:17 +0000 (+0000) Subject: A follow-on commit to the previous @oc support change to use anlist X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~509 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e4d199d7bb4cf218113168b2f1f01dd354f8c9c7;p=openldap A follow-on commit to the previous @oc support change to use anlist --- diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 6896f9a353..9b5805363e 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -811,14 +811,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) adname.bv_val = &anew->an_name.bv_val[1]; slap_bv2ad(&adname, &anew->an_desc, &text); if ( !anew->an_desc ) { - free( an ); - free( str ); - /* - * overwrites input string - * on error! - */ - strcpy( in, s ); - return NULL; + goto reterr; } } break; @@ -830,14 +823,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) ocname.bv_val = &anew->an_name.bv_val[1]; anew->an_oc = oc_bvfind( &ocname ); if ( !anew->an_oc ) { - free( an ); - free( str ); - /* - * overwrites input string - * on error! - */ - strcpy( in, s ); - return NULL; + goto reterr; } if ( anew->an_name.bv_val[0] == '!' ) { @@ -849,11 +835,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) /* old (deprecated) way */ anew->an_oc = oc_bvfind( &anew->an_name ); if ( !anew->an_oc ) { - free( an ); - free( str ); - /* overwrites input string on error! */ - strcpy( in, s ); - return NULL; + goto reterr; } } } @@ -863,6 +845,19 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) anew->an_name.bv_val = NULL; free( str ); return( an ); + +reterr: + for ( i = 0; an[i].an_name.bv_val; i++ ) { + free( an[i].an_name.bv_val ); + } + free( an ); + /* + * overwrites input string + * on error! + */ + strcpy( in, s ); + free( str ); + return NULL; } char **anlist2charray_x( AttributeName *an, int dup, void *ctx ) @@ -964,7 +959,8 @@ anlist2attrs( AttributeName * anlist ) } } - attrs = (char **) ch_realloc( attrs, (i+1) * sizeof( char * )); + if ( i != n ) + attrs = (char **) ch_realloc( attrs, (i+1) * sizeof( char * )); return attrs; } diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 4e7d25acda..e6e7675f47 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -483,11 +483,13 @@ int backend_destroy(void) syncinfo_free( si_entry ); } - LDAP_TAILQ_FOREACH( csne, bd->be_pending_csn_list, ce_csn_link ) { - LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link ); - ch_free( csne->ce_csn->bv_val ); - ch_free( csne->ce_csn ); - ch_free( csne ); + if ( bd->be_pending_csn_list ) { + LDAP_TAILQ_FOREACH( csne, bd->be_pending_csn_list, ce_csn_link ) { + LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link ); + ch_free( csne->ce_csn->bv_val ); + ch_free( csne->ce_csn ); + ch_free( csne ); + } } if ( bd->bd_info->bi_db_destroy ) { diff --git a/servers/slapd/config.c b/servers/slapd/config.c index ef307d8811..0b65dd33df 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -2312,6 +2312,7 @@ add_syncrepl( if ( rc < 0 || duplicated_replica_id ) { Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 ); + syncinfo_free( si ); return 1; } else { Debug( LDAP_DEBUG_CONFIG, diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 4d7187ced0..7346da5cd3 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -83,7 +83,9 @@ init_syncrepl(syncinfo_t *si) i++; } } - attrs = ( char ** ) ch_realloc( attrs, (i + 1)*sizeof( char * )); + attrs = ( char ** ) ch_realloc( attrs, (i + 2)*sizeof( char * )); + attrs[i] = ch_strdup("*"); + attrs[i + 1] = NULL; } else if ( si->si_allopattrs ) { i = 0; while ( attrs[i] ) { @@ -97,7 +99,9 @@ init_syncrepl(syncinfo_t *si) i++; } } - attrs = ( char ** ) ch_realloc( attrs, (i + 1)*sizeof( char * )); + attrs = ( char ** ) ch_realloc( attrs, (i + 2)*sizeof( char * )); + attrs[i] = ch_strdup("+"); + attrs[i + 1] = NULL; } if ( !si->si_allopattrs ) { @@ -143,8 +147,11 @@ init_syncrepl(syncinfo_t *si) exattrs = anlist2attrs( si->si_exanlist ); + if ( exattrs ) { + for ( n = 0; exattrs[n] != NULL; n++ ) ; + for ( i = 0; sync_descs[i] != NULL; i++ ) { j = 0; while ( exattrs[j] != NULL ) { @@ -181,7 +188,9 @@ init_syncrepl(syncinfo_t *si) } for ( i = 0; exattrs[i] != NULL; i++ ) ; - exattrs = (char **) ch_realloc( exattrs, (i + 1)*sizeof(char *)); + + if ( i != n ) + exattrs = (char **) ch_realloc( exattrs, (i + 1)*sizeof(char *)); } si->si_exattrs = exattrs;