Fix mem leak on error path

The mem pointed to by cAB can be leaked on an error path.

Reviewed-by: Tim Hudson <tjh@openssl.org>
This commit is contained in:
Matt Caswell 2016-08-22 23:20:45 +01:00
parent c72b8e069d
commit 85d6b09dda

View File

@ -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;