mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
stop strtod() warning; add more checks; close #247
This commit is contained in:
+9
-2
@@ -4128,8 +4128,15 @@ parser_yylex(parser_state *p)
|
||||
}
|
||||
tokfix(p);
|
||||
if (is_float) {
|
||||
(void)strtod(tok(p), 0); /* just check if float is within range */
|
||||
if (errno == ERANGE) {
|
||||
double d;
|
||||
char *endp;
|
||||
|
||||
errno = 0;
|
||||
d = strtod(tok(p), &endp);
|
||||
if (d == 0 && endp == tok(p)) {
|
||||
yywarning_s(p, "corrupted float value %s", tok(p));
|
||||
}
|
||||
else if (errno == ERANGE) {
|
||||
yywarning_s(p, "float %s out of range", tok(p));
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user