summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_sqrt.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2005-08-23 04:14:40 +0000
committerBodo Möller <bodo@openssl.org>2005-08-23 04:14:40 +0000
commit7534d131d676431f1299618dfe0decd1a42680bb (patch)
tree376f15f3b85798158dcb98aa07ae1390c5f57349 /crypto/bn/bn_sqrt.c
parent7f3c9036ea1be59c07ab85624d53d6e244dbe851 (diff)
avoid potential spurious BN_free()
Submitted by: David Heine <dlheine@suif.Stanford.EDU>
Diffstat (limited to 'crypto/bn/bn_sqrt.c')
-rw-r--r--crypto/bn/bn_sqrt.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/bn/bn_sqrt.c b/crypto/bn/bn_sqrt.c
index c1eb7f6d49..6beaf9e5e5 100644
--- a/crypto/bn/bn_sqrt.c
+++ b/crypto/bn/bn_sqrt.c
@@ -83,7 +83,8 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
goto end;
if (!BN_set_word(ret, BN_is_bit_set(a, 0)))
{
- BN_free(ret);
+ if (ret != in)
+ BN_free(ret);
return NULL;
}
bn_check_top(ret);
@@ -102,7 +103,8 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
goto end;
if (!BN_set_word(ret, BN_is_one(a)))
{
- BN_free(ret);
+ if (ret != in)
+ BN_free(ret);
return NULL;
}
bn_check_top(ret);