diff --git a/util.c b/util.c index 449d4bf439..6c18543347 100644 --- a/util.c +++ b/util.c @@ -783,9 +783,9 @@ ruby_strtod(string, endPtr) * and also locate the decimal point. */ - for ( ; c = *p; p++) { + for ( ; (c = *p) != '\0'; p++) { if (!ISDIGIT(c)) { - if (c != '.' || hasPoint) { + if (c != '.' || hasPoint || !ISDIGIT(p[1])) { break; } hasPoint = Qtrue;