improve previous commit

This commit is contained in:
Pierangelo Masarati 2004-03-05 10:53:35 +00:00
parent 127cdb6432
commit 8aedfad3bb

View File

@ -3253,7 +3253,10 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
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;
}
@ -3306,6 +3309,8 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
}
if ( trailing_slash ) {
/* the DN is exactly a domain -- need a trailing
* slash; room was reserved in advance */
bv->bv_val[ len ] = '/';
len++;
}
@ -3313,7 +3318,6 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
bv->bv_len = len;
bv->bv_val[ bv->bv_len ] = '\0';
rc = LDAP_SUCCESS;
} break;