Fix error handling in bn_exp
[openssl.git] / crypto / bn / bn_exp.c
index fca401450a3311b8086e2981765270bfe3ca67e7..27146c89e74001f5574c47ca0db091500ce48b20 100644 (file)
@@ -168,10 +168,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);