diff options
author | whitequark <whitequark@whitequark.org> | 2020-05-29 09:04:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 09:04:27 +0000 |
commit | 626c74adbdc25c84382d790f8be69713dd57021a (patch) | |
tree | 977a2ff917e23c79a523a2a65b28455dabc7ec71 /frontends | |
parent | 2116d9500c6abc1b52871b7f7e429b177f8d6bed (diff) | |
parent | 13b2963dedebf86129574192b0d4719956e93d82 (diff) | |
download | yosys-626c74adbdc25c84382d790f8be69713dd57021a.tar.gz yosys-626c74adbdc25c84382d790f8be69713dd57021a.tar.bz2 yosys-626c74adbdc25c84382d790f8be69713dd57021a.zip |
Merge pull request #2097 from whitequark/ilang_lexer-fix-erange
ilang_lexer: fix check for out of range literal
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/ilang/ilang_lexer.l | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/frontends/ilang/ilang_lexer.l b/frontends/ilang/ilang_lexer.l index 62f53d18e..3362ed641 100644 --- a/frontends/ilang/ilang_lexer.l +++ b/frontends/ilang/ilang_lexer.l @@ -91,8 +91,10 @@ USING_YOSYS_NAMESPACE [0-9]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; } -?[0-9]+ { char *end = nullptr; + errno = 0; long value = strtol(yytext, &end, 10); - if (end != yytext + strlen(yytext)) + log_assert(end == yytext + strlen(yytext)); + if (errno == ERANGE) return TOK_INVALID; // literal out of range of long if (value < INT_MIN || value > INT_MAX) return TOK_INVALID; // literal out of range of int (relevant mostly for LP64 platforms) |