Fixing overflow detection when reading hex bignums.

This commit is contained in:
Alex Shinn 2014-06-25 22:46:34 +09:00
parent d26de4b701
commit 908d46f662
2 changed files with 5 additions and 1 deletions

3
sexp.c
View file

@ -2621,7 +2621,8 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
break;
tmp = val * base + digit;
#if SEXP_USE_BIGNUMS
if ((tmp < val) || (tmp > SEXP_MAX_FIXNUM)) {
if ((SEXP_MAX_FIXNUM / base < val) ||
(tmp < val) || (tmp > SEXP_MAX_FIXNUM)) {
sexp_push_char(ctx, c, in);
return sexp_read_bignum(ctx, in, val, (negativep ? -1 : 1), base);
}

View file

@ -167,6 +167,9 @@
(test #f (>= -inf.0 +inf.0))
(test #f (> -inf.0 +inf.0))
(test 88962710306127702866241727433142015
(string->number "#x00112233445566778899aabbccddeeff"))
(test (expt 10 154) (sqrt (expt 10 308)))
(test 36893488147419103231