summaryrefslogtreecommitdiff
path: root/3rdparty/libconfig/extra/gen/scanner.l
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/libconfig/extra/gen/scanner.l')
-rw-r--r--3rdparty/libconfig/extra/gen/scanner.l12
1 files changed, 8 insertions, 4 deletions
diff --git a/3rdparty/libconfig/extra/gen/scanner.l b/3rdparty/libconfig/extra/gen/scanner.l
index 4b3048fab..66364e019 100644
--- a/3rdparty/libconfig/extra/gen/scanner.l
+++ b/3rdparty/libconfig/extra/gen/scanner.l
@@ -86,6 +86,13 @@ static unsigned long long fromhex(const char *s)
#endif /* __MINGW32__ */
}
+static int fromihex(const char *s) {
+ unsigned long l = strtoul(s, NULL, 16);
+ if (l > INT32_MAX)
+ l = INT32_MAX;
+ return (int)l;
+}
+
%}
true [Tt][Rr][Uu][Ee]
@@ -178,10 +185,7 @@ include_open ^[ \t]*@include[ \t]+\"
{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); }
{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
-{hex} {
- yylval->ival = strtoul(yytext, NULL, 16);
- return(TOK_HEX);
- }
+{hex} { yylval->ival = fromihex(yytext); return(TOK_HEX); }
{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
\[ { return(TOK_ARRAY_START); }
\] { return(TOK_ARRAY_END); }