From c02f148fa8c23f71ed830996cf29e81185e82488 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 18 Mar 2015 19:51:13 -0400 Subject: [PATCH] Fix error handling in bn_exp In the event of an error |rr| could be NULL. Therefore don't assume you can use |rr| in the error handling code. (Imported from upstream's 8c5a7b33c6269c3bd6bc0df6b4c22e4fba03b485.) Change-Id: I0b392991ce8170dc418e93003af256d535d1e2e8 Reviewed-on: https://boringssl-review.googlesource.com/4005 Reviewed-by: Adam Langley --- crypto/bn/exponentiation.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/bn/exponentiation.c b/crypto/bn/exponentiation.c index 3a077048..57f319ae 100644 --- a/crypto/bn/exponentiation.c +++ b/crypto/bn/exponentiation.c @@ -172,12 +172,13 @@ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { } } } - ret = 1; -err: if (r != rr) { BN_copy(r, rr); } + ret = 1; + +err: BN_CTX_end(ctx); return ret; }