diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-06-08 05:51:39 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-06-08 05:51:39 -0700 |
commit | d8ce6dd806ea12ebafa312f6bb7f762084efd37a (patch) | |
tree | 5f4b4bf2df7aec19cda3ae42fc90e8c5e1ee4422 /arith.c | |
parent | ede703bad4192140ac637a2bff3603e5a5567510 (diff) | |
download | txr-d8ce6dd806ea12ebafa312f6bb7f762084efd37a.tar.gz txr-d8ce6dd806ea12ebafa312f6bb7f762084efd37a.tar.bz2 txr-d8ce6dd806ea12ebafa312f6bb7f762084efd37a.zip |
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.
Diffstat (limited to 'arith.c')
-rw-r--r-- | arith.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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; } |