From: Kurt Zeilenga Date: Fri, 11 Jun 1999 18:48:34 +0000 (+0000) Subject: Clean up build_result_ber error handling. X-Git-Tag: OPENLDAP_REL_ENG_2_BP~341 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2cb228a9cebd2ee13b4a5e318ebb8bc295d75745;p=openldap Clean up build_result_ber error handling. --- diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 8fa906c57a..5f9ff57cec 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -540,9 +540,11 @@ build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) long along; BerElement *ber; - ber = *bp = ldap_alloc_ber_with_options( ld ); + *bp = NULL; + ber = ldap_alloc_ber_with_options( ld ); if( ber == NULL ) { + ld->ld_errno = LDAP_NO_MEMORY; return LBER_ERROR; } @@ -552,6 +554,7 @@ build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } @@ -559,11 +562,13 @@ build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) if ( ber_skip_tag( ber, &len ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } if ( ber_get_int( ber, &along ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } @@ -571,9 +576,11 @@ build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) if ( tag == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } + *bp = ber; return tag; }