diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-07-04 10:19:10 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-07-04 10:19:10 +0900 |
| commit | f141ae42c0ad52ef37694ae195f5841ea2678b4f (patch) | |
| tree | 35b59488f8a030a9579ee5a66351ba18917c5af0 | |
| parent | cad95d3d1888826bbf0f175e61a6b632ce9384cf (diff) | |
| download | mruby-f141ae42c0ad52ef37694ae195f5841ea2678b4f.tar.gz mruby-f141ae42c0ad52ef37694ae195f5841ea2678b4f.zip | |
stop strtod() warning; add more checks; close #247
| -rw-r--r-- | src/parse.y | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/parse.y b/src/parse.y index 2b69ac726..025707670 100644 --- a/src/parse.y +++ b/src/parse.y @@ -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; } |
