mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Fixing overflow detection when reading hex bignums.
This commit is contained in:
parent
d26de4b701
commit
908d46f662
2 changed files with 5 additions and 1 deletions
3
sexp.c
3
sexp.c
|
@ -2621,7 +2621,8 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
|
||||||
break;
|
break;
|
||||||
tmp = val * base + digit;
|
tmp = val * base + digit;
|
||||||
#if SEXP_USE_BIGNUMS
|
#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);
|
sexp_push_char(ctx, c, in);
|
||||||
return sexp_read_bignum(ctx, in, val, (negativep ? -1 : 1), base);
|
return sexp_read_bignum(ctx, in, val, (negativep ? -1 : 1), base);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,6 +167,9 @@
|
||||||
(test #f (>= -inf.0 +inf.0))
|
(test #f (>= -inf.0 +inf.0))
|
||||||
(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 (expt 10 154) (sqrt (expt 10 308)))
|
||||||
|
|
||||||
(test 36893488147419103231
|
(test 36893488147419103231
|
||||||
|
|
Loading…
Add table
Reference in a new issue