summaryrefslogtreecommitdiffstats
path: root/mpi
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-22 06:57:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-22 06:57:32 -0700
commit5bcfa40f0831c3f2ff266a260e0ca751b092b734 (patch)
tree7b6dd4db189503c18b645a95e0c546d91a76232b /mpi
parent81da1829a7b79676d36e0684aed8b5b587fffc09 (diff)
downloadtxr-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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mpi/mpi.c b/mpi/mpi.c
index 0e01fc26..e5d76f93 100644
--- a/mpi/mpi.c
+++ b/mpi/mpi.c
@@ -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)