From: Bodo Möller Date: Tue, 23 Aug 2005 04:14:55 +0000 (+0000) Subject: avoid potential spurious BN_free() X-Git-Tag: OpenSSL_0_9_8a~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9eaf7e14c7f831f8b538d2418c48538624d72039;p=openssl avoid potential spurious BN_free() Submitted by: David Heine --- 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);