summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_div.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2002-05-30 16:47:45 +0000
committerRichard Levitte <levitte@openssl.org>2002-05-30 16:47:45 +0000
commit9cdf87f19431b32a50b12e468cf2a9557cfc3568 (patch)
tree5aa5e1f88093d6b8013b9e2f1af0b18201b9bef6 /crypto/bn/bn_div.c
parenta81e9d3dc45f29c1a5fde7fa641a43f796fe92d4 (diff)
Check the return values where memory allocation failures may happen.
PR: 49
Diffstat (limited to 'crypto/bn/bn_div.c')
-rw-r--r--crypto/bn/bn_div.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c
index ac1a09615a..f9a095e3b3 100644
--- a/crypto/bn/bn_div.c
+++ b/crypto/bn/bn_div.c
@@ -200,10 +200,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
/* First we normalise the numbers */
norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
- BN_lshift(sdiv,divisor,norm_shift);
+ if (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;
sdiv->neg=0;
norm_shift+=BN_BITS2;
- BN_lshift(snum,num,norm_shift);
+ if (!(BN_lshift(snum,num,norm_shift))) goto err;
snum->neg=0;
div_n=sdiv->top;
num_n=snum->top;
@@ -327,7 +327,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
tmp->top=j;
j=wnum.top;
- BN_sub(&wnum,&wnum,tmp);
+ if (!BN_sub(&wnum,&wnum,tmp)) goto err;
snum->top=snum->top+wnum.top-j;
@@ -335,7 +335,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
{
q--;
j=wnum.top;
- BN_add(&wnum,&wnum,sdiv);
+ if (!BN_add(&wnum,&wnum,sdiv)) goto err;
snum->top+=wnum.top-j;
}
*(resp--)=q;