]> granicus.if.org Git - openssl/commitdiff
Fix error handling in bn_exp
authorMatt Caswell <matt@openssl.org>
Wed, 11 Mar 2015 15:31:16 +0000 (15:31 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 12 Mar 2015 09:18:22 +0000 (09:18 +0000)
In the event of an error |rr| could be NULL. Therefore don't assume you can
use |rr| in the error handling code.

Reviewed-by: Andy Polyakov <appro@openssl.org>
crypto/bn/bn_exp.c

index 28a9fd53bbfc69ebba461c52ad8a1399de441410..8c46e50bdcc9783d6bdd3ab056cae2547a62c92b 100644 (file)
@@ -185,10 +185,10 @@ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
                 goto err;
         }
     }
-    ret = 1;
- err:
     if (r != rr)
         BN_copy(r, rr);
+    ret = 1;
+ err:
     BN_CTX_end(ctx);
     bn_check_top(r);
     return (ret);