Fixes for scan-build warnings. Fix possible memory leak in wolfSSL_DH_new on failure. Add null checks in integer.c for destination to make sure “dp” grows when NULL (even though never happens in real-use). Added suppression of wc_port.c warning “Value stored to 'ret' is never read”.

This commit is contained in:
David Garske
2017-02-23 14:47:36 -08:00
parent 6425a654be
commit 9db6a27921
3 changed files with 4 additions and 2 deletions

View File

@ -16133,6 +16133,7 @@ WOLFSSL_DH* wolfSSL_DH_new(void)
if (wc_InitDhKey(key) != 0) {
WOLFSSL_MSG("wolfSSL_DH_new InitDhKey failure");
XFREE(key, NULL, DYNAMIC_TYPE_DH);
XFREE(external, NULL, DYNAMIC_TYPE_DH);
return NULL;
}
external->internal = key;

View File

@ -330,7 +330,7 @@ int mp_copy (mp_int * a, mp_int * b)
}
/* grow dest */
if (b->alloc < a->used) {
if (b->alloc < a->used || b->dp == NULL) {
if ((res = mp_grow (b, a->used)) != MP_OKAY) {
return res;
}
@ -1633,7 +1633,7 @@ int s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
max_a = a->used;
/* init result */
if (c->alloc < max_a) {
if (c->alloc < max_a || c->dp == NULL) {
if ((res = mp_grow (c, max_a)) != MP_OKAY) {
return res;
}

View File

@ -78,6 +78,7 @@ int wolfCrypt_Init(void)
WOLFSSL_MSG(ippGetStatusString(ret));
WOLFSSL_MSG("Using default fast IPP library");
ret = 0;
(void)ret; /* suppress not read warning */
}
#endif