summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_sqr.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/bn/bn_sqr.c')
-rw-r--r--crypto/bn/bn_sqr.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c
index 3ca69879ee..256d26e8db 100644
--- a/crypto/bn/bn_sqr.c
+++ b/crypto/bn/bn_sqr.c
@@ -143,8 +143,9 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
rr->top = max - 1;
else
rr->top = max;
- if (rr != r)
- BN_copy(r, rr);
+ if (r != rr && BN_copy(r, rr) == NULL)
+ goto err;
+
ret = 1;
err:
bn_check_top(rr);