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;
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] == '!' ) {
/* 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;
}
}
}
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 )
}
}
- attrs = (char **) ch_realloc( attrs, (i+1) * sizeof( char * ));
+ if ( i != n )
+ attrs = (char **) ch_realloc( attrs, (i+1) * sizeof( char * ));
return attrs;
}
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 ) {
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,
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] ) {
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 ) {
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 ) {
}
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;