Commit
d5aa14dd simplified the bn_expand_internal() and BN_copy() functions.
Unfortunately it also removed some checks which are still required,
otherwise we call memcpy passing in NULL which is not allowed.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2836)
}
assert(b->top <= words);
- memcpy(a, b->d, sizeof(*a) * b->top);
+ if (b->top > 0)
+ memcpy(a, b->d, sizeof(*a) * b->top);
return a;
}
if (bn_wexpand(a, b->top) == NULL)
return NULL;
- memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
+ if (b->top > 0)
+ memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
a->top = b->top;
a->neg = b->neg;