diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-10-22 06:57:32 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-10-22 06:57:32 -0700 |
commit | 5bcfa40f0831c3f2ff266a260e0ca751b092b734 (patch) | |
tree | 7b6dd4db189503c18b645a95e0c546d91a76232b /mpi | |
parent | 81da1829a7b79676d36e0684aed8b5b587fffc09 (diff) | |
download | txr-5bcfa40f0831c3f2ff266a260e0ca751b092b734.tar.gz txr-5bcfa40f0831c3f2ff266a260e0ca751b092b734.tar.bz2 txr-5bcfa40f0831c3f2ff266a260e0ca751b092b734.zip |
mpi: memory leak in mp_bit.
* mpi.c (mp_bit): If the argument is negative, and we have
produced a temporary mp_int, we must clear it before
returning.
Diffstat (limited to 'mpi')
-rw-r--r-- | mpi/mpi.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2404,7 +2404,12 @@ mp_err mp_bit(mp_int *a, mp_size bit) a = &tmp; } - return (digit < USED(a) && (DIGITS(a)[digit] & mask) != 0) ? MP_YES : MP_NO; + res = (digit < USED(a) && (DIGITS(a)[digit] & mask) != 0) ? MP_YES : MP_NO; + + if (a_neg) + mp_clear(&tmp); + + return res; } mp_err mp_to_double(mp_int *mp, double *d) |