len += rdnl;
}
- if ( ( bv->bv_val = LDAP_MALLOCX( len + 2, ctx ) ) == NULL ) {
+ /* reserve room for trailing '/' in case the DN
+ * is exactly a domain */
+ if ( ( bv->bv_val = LDAP_MALLOCX( len + 1 + 1, ctx ) ) == NULL )
+ {
rc = LDAP_NO_MEMORY;
break;
}
}
if ( trailing_slash ) {
+ /* the DN is exactly a domain -- need a trailing
+ * slash; room was reserved in advance */
bv->bv_val[ len ] = '/';
len++;
}
bv->bv_len = len;
bv->bv_val[ bv->bv_len ] = '\0';
-
rc = LDAP_SUCCESS;
} break;