Skip to content

Commit

Permalink
Check overflow in integer literals
Browse files Browse the repository at this point in the history
Make this:
>> 9'999'999'999'999'999'999
== 9223372036854775807

become:
>> 9'999'999'999'999'999'999
** Syntax error: invalid "integer" -- "9'999'999'999'999'999'999"
** Near: (line 1) 9'999'999'999'999'999'999

zsx#8
  • Loading branch information
zsx committed Aug 20, 2014
1 parent 9876dc7 commit 2306206
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/l-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ bad_hex: Trap0(RE_INVALID_CHARS);
if (len > 19) return 0;

// Convert, check, and return:
errno = 0;
n = CHR_TO_INT(buf);
if (errno != 0) return 0; //overflow
if ((n > 0 && neg) || (n < 0 && !neg)) return 0;
SET_INTEGER(value, n);
return cp;
Expand Down

0 comments on commit 2306206

Please sign in to comment.