summaryrefslogtreecommitdiffstats
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
commit391d251d7902bcd14346d40b8b12cf49367e4148 (patch)
tree7b6dd4db189503c18b645a95e0c546d91a76232b
parent07a3bb418d6b96f4af25b37c3020af4c564eaac1 (diff)
downloadtxr-391d251d7902bcd14346d40b8b12cf49367e4148.tar.gz
txr-391d251d7902bcd14346d40b8b12cf49367e4148.tar.bz2
txr-391d251d7902bcd14346d40b8b12cf49367e4148.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.
-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)