From: Matt Caswell Date: Mon, 22 Aug 2016 22:20:45 +0000 (+0100) Subject: Fix mem leak on error path X-Git-Tag: OpenSSL_1_1_0~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85d6b09ddaf32a67a351521f84651c3193286663;p=openssl Fix mem leak on error path The mem pointed to by cAB can be leaked on an error path. Reviewed-by: Tim Hudson --- diff --git a/crypto/srp/srp_lib.c b/crypto/srp/srp_lib.c index 9efad9352f..f146f820e7 100644 --- a/crypto/srp/srp_lib.c +++ b/crypto/srp/srp_lib.c @@ -84,7 +84,7 @@ BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N) || !EVP_DigestUpdate(ctxt, cAB + BN_bn2bin(A, cAB + longN), longN) || !EVP_DigestUpdate(ctxt, cAB + BN_bn2bin(B, cAB + longN), longN)) goto err; - OPENSSL_free(cAB); + if (!EVP_DigestFinal_ex(ctxt, cu, NULL)) goto err; @@ -94,7 +94,9 @@ BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N) BN_free(u); u = NULL; } + err: + OPENSSL_free(cAB); EVP_MD_CTX_free(ctxt); return u;