diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-11 11:30:48 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-11 11:34:44 -0700 |
commit | 038a09041af20ed373b15715fbc859d4a305dda8 (patch) | |
tree | bad4ad02fbf3f18637563b29dbe49eecff319bdb /src/bignum.c | |
parent | fa3785ea5fd73eaba84b8e3b8f988dd53f3a4148 (diff) | |
download | emacs-038a09041af20ed373b15715fbc859d4a305dda8.tar.gz |
Fix (round 1e+INF) core dump
* src/bignum.c (double_to_integer): Signal an error
if D cannot be converted, instead of dumping core.
* test/src/floatfns-tests.el (special-round): New test.
Diffstat (limited to 'src/bignum.c')
-rw-r--r-- | src/bignum.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bignum.c b/src/bignum.c index 2da2c961c47..5e86c404b70 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include "lisp.h" +#include <math.h> #include <stdlib.h> /* mpz global temporaries. Making them global saves the trouble of @@ -64,10 +65,13 @@ bignum_to_double (Lisp_Object n) return mpz_get_d (XBIGNUM (n)->value); } -/* Return D, converted to a Lisp integer. Discard any fraction. */ +/* Return D, converted to a Lisp integer. Discard any fraction. + Signal an error if D cannot be converted. */ Lisp_Object double_to_integer (double d) { + if (!isfinite (d)) + overflow_error (); mpz_set_d (mpz[0], d); return make_integer_mpz (); } |