From: Kurt Zeilenga Date: Tue, 6 Nov 2001 17:49:17 +0000 (+0000) Subject: Fix realloc bug X-Git-Tag: OPENLDAP_REL_ENG_2_0_19~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc252601f2b2a6e4659f585482313b7824c53381;p=thirdparty%2Fopenldap.git Fix realloc bug --- diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index d2fbcdd357..6970826252 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -585,9 +585,17 @@ ber_scanf ( BerElement *ber, tag != LBER_DEFAULT && rc != LBER_DEFAULT; tag = ber_next_element( ber, &len, last ) ) { + void *save = *sss; + *sss = (char **) LBER_REALLOC( *sss, (j + 2) * sizeof(char *) ); + if( *sss == NULL ) { + LBER_FREE( save ); + rc = LBER_DEFAULT; + goto breakout; + } + rc = ber_get_stringa( ber, &((*sss)[j]) ); j++; } @@ -603,9 +611,17 @@ ber_scanf ( BerElement *ber, tag != LBER_DEFAULT && rc != LBER_DEFAULT; tag = ber_next_element( ber, &len, last ) ) { + void *save = *bv; + *bv = (struct berval **) LBER_REALLOC( *bv, (j + 2) * sizeof(struct berval *) ); + if( *bv == NULL ) { + LBER_FREE( save ); + rc = LBER_DEFAULT; + goto breakout; + } + rc = ber_get_stringal( ber, &((*bv)[j]) ); j++; } @@ -639,6 +655,7 @@ ber_scanf ( BerElement *ber, } } +breakout: va_end( ap ); if ( rc == LBER_DEFAULT ) {