From 85d6b09ddaf32a67a351521f84651c3193286663 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 22 Aug 2016 23:20:45 +0100 Subject: [PATCH] Fix mem leak on error path The mem pointed to by cAB can be leaked on an error path. Reviewed-by: Tim Hudson --- crypto/srp/srp_lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.34.1