X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbn%2Fbn_sqr.c;h=65bbf165d0e2f3bc3de3d662c1c02800dbb33c70;hp=8831daa390a7be5cdbb0bc7815cfb6ebe0efb6b1;hb=55614f89f0beb53ebafbfc680cf7b4d114b44d30;hpb=b6358c89a10128692875fb92921b663c4d079a1e diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index 8831daa390..65bbf165d0 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -77,6 +77,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) if (al <= 0) { r->top=0; + r->neg = 0; return 1; } @@ -86,7 +87,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) if (!rr || !tmp) goto err; max = 2 * al; /* Non-zero (from above) */ - if (bn_wexpand(rr,max+1) == NULL) goto err; + if (bn_wexpand(rr,max) == NULL) goto err; if (al == 4) { @@ -148,8 +149,8 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) if (rr != r) BN_copy(r,rr); ret = 1; err: - if(rr) bn_check_top(rr); - if(tmp) bn_check_top(tmp); + bn_check_top(rr); + bn_check_top(tmp); BN_CTX_end(ctx); return(ret); }