{
int i, num_components = ldb_dn_get_comp_num(dn);
char *dns_name = talloc_strdup(mem_ctx, "");
- if (dns_name == NULL) {
- return NULL;
- }
for (i=0; i<num_components; i++) {
const struct ldb_val *v = ldb_dn_get_component_val(dn, i);
- char *s;
if (v == NULL) {
talloc_free(dns_name);
return NULL;
}
- s = talloc_asprintf_append_buffer(dns_name, "%*.*s.",
- (int)v->length, (int)v->length, (char *)v->data);
- if (s == NULL) {
- talloc_free(dns_name);
- return NULL;
- }
- dns_name = s;
+ talloc_asprintf_addbuf(&dns_name,
+ "%*.*s.",
+ (int)v->length,
+ (int)v->length,
+ (char *)v->data);
+ }
+
+ if (dns_name == NULL) {
+ return NULL;
}
/* remove the last '.' */