(perl #131526) don't go beyond the end of the NUL in my_atof2
authorTony Cook <tony@develop-help.com>
Tue, 13 Jun 2017 23:42:31 +0000 (09:42 +1000)
committerTony Cook <tony@develop-help.com>
Tue, 13 Jun 2017 23:42:31 +0000 (09:42 +1000)
Perl_my_atof2() calls GROK_NUMERIC_RADIX() to detect and skip past
a decimal point and then can increment the parse pointer (s) before
checking what it points at, so skipping the terminating NUL if the
decimal point is immediately before the NUL.

numeric.c

index 6ea6968..5771907 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -1485,9 +1485,9 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value)
        else if (!seen_dp && GROK_NUMERIC_RADIX(&s, send)) {
            seen_dp = 1;
            if (sig_digits > MAX_SIG_DIGITS) {
-               do {
+               while (isDIGIT(*s)) {
                    ++s;
-               } while (isDIGIT(*s));
+               }
                break;
            }
        }