From 67a8626430737d821a36eddcc574a54a7266e661 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 2 Mar 2017 15:56:31 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20for=20scan-build=20warning=20with=20?= =?UTF-8?q?=E2=80=9C->dp=20=3D=3D=20NULL=E2=80=9D.=20Scenario=20can?= =?UTF-8?q?=E2=80=99t=20happen,=20but=20adding=20sanity=20check=20to=20sup?= =?UTF-8?q?press=20warning.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wolfcrypt/src/integer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index 067a55012..c5026bf6d 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -330,12 +330,16 @@ int mp_copy (mp_int * a, mp_int * b) } /* grow dest */ - if (b->alloc < a->used || b->dp == NULL) { + if (b->alloc < a->used) { if ((res = mp_grow (b, a->used)) != MP_OKAY) { return res; } } + /* sanity check on destination */ + if (b->dp == NULL) + return MP_VAL; + /* zero b and copy the parameters over */ { mp_digit *tmpa, *tmpb; @@ -1633,11 +1637,16 @@ int s_mp_sub (mp_int * a, mp_int * b, mp_int * c) max_a = a->used; /* init result */ - if (c->alloc < max_a || c->dp == NULL) { + if (c->alloc < max_a) { if ((res = mp_grow (c, max_a)) != MP_OKAY) { return res; } } + + /* sanity check on destination */ + if (c->dp == NULL) + return MP_VAL; + olduse = c->used; c->used = max_a;