From d8ce6dd806ea12ebafa312f6bb7f762084efd37a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 8 Jun 2016 05:51:39 -0700 Subject: Do not leave COBJ-ified mp_int uninitialized. Here we ensure that the digits pointer of an uninitialized mp_int is nulled out. The garbage collector could conceivably encounter such an object, in which case mp_clear will then try to free a garbage pointer. This could happen if an exception is thrown out of numeric code due to low memory, interrupting its execution, leaving behind an unfilled object produced by make_ubignum. * arith.c (make_ubignum): Perform minimal initialization of the mp_int using new function. * mpi/mpi.h (mp_init_minimal): New inline function. --- arith.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arith.c') diff --git a/arith.c b/arith.c index 1c3c33ce..5eb022ec 100644 --- a/arith.c +++ b/arith.c @@ -62,6 +62,7 @@ static val make_ubignum(void) { val n = make_obj(); n->bn.type = BGNUM; + mp_init_minimal(&n->bn.mp); return n; } -- cgit v1.2.3