Fix leak when mp_int = 0 in integer.c

This commit is contained in:
Juliusz Sosinowicz
2021-12-07 12:46:24 +01:00
parent 96b8b11fba
commit 574d171357

View File

@ -183,7 +183,13 @@ void mp_clear (mp_int * a)
return; return;
/* only do anything if a hasn't been freed previously */ /* only do anything if a hasn't been freed previously */
if (a->dp != NULL) { #ifndef HAVE_WOLF_BIGINT
/* When HAVE_WOLF_BIGINT then mp_free -> wc_bigint_free needs to be called
* because a->raw->buf may be allocated even when a->dp == NULL. This is the
* case for when a zero is loaded into the mp_int. */
if (a->dp != NULL)
#endif
{
/* first zero the digits */ /* first zero the digits */
for (i = 0; i < a->used; i++) { for (i = 0; i < a->used; i++) {
a->dp[i] = 0; a->dp[i] = 0;