From f9964fe5c922535d5284ad22d62fddbdca315e97 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 18 Jun 2017 08:34:08 -0700 Subject: Handle returns of MPI functions that return MP_TOOBIG. * arith.c (do_mp_error): New function. (num_from_buffer, plus, minus, mul, floordiv, expt, exptmod, logtrunc, sign_extend, ash, bit): Handle errors from select MPI functions: those that have the mp_ign attribute. * ffi.c (unum_carray, num_carray): Likewise. * rand.c (random): Likewise. --- ffi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ffi.c') diff --git a/ffi.c b/ffi.c index f8e133c9..fab5fa1e 100644 --- a/ffi.c +++ b/ffi.c @@ -4887,9 +4887,9 @@ val unum_carray(val carray) struct txr_ffi_type *etft = scry->eltft; ucnum size = (ucnum) etft->size * (ucnum) scry->nelem; val ubn = make_bignum(); - if ((ucnum) (int) size != size) - uw_throwf(error_s, lit("~a: bignum size overflow"), self, nao); - mp_read_unsigned_bin(mp(ubn), scry->data, size); + mp_err mpe = mp_read_unsigned_bin(mp(ubn), scry->data, size); + if (mpe != MP_OKAY) + do_mp_error(self, mpe); return normalize(ubn); } @@ -4901,9 +4901,9 @@ val num_carray(val carray) ucnum size = (ucnum) etft->size * (ucnum) scry->nelem; ucnum bits = size * 8; val ubn = make_bignum(); - if ((ucnum) (int) size != size || bits / 8 != size) - uw_throwf(error_s, lit("~a: bignum size overflow"), self, nao); - mp_read_unsigned_bin(mp(ubn), scry->data, size); + mp_err mpe = mp_read_unsigned_bin(mp(ubn), scry->data, size); + if (mpe != MP_OKAY) + do_mp_error(self, mpe); return sign_extend(normalize(ubn), unum(bits)); } -- cgit v1.2.3