This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #127334] S_incline: avoid overrunning the end of the parse buffer
authorTony Cook <tony@develop-help.com>
Wed, 10 Feb 2016 05:03:22 +0000 (16:03 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 10 Feb 2016 05:03:22 +0000 (16:03 +1100)
If the rest of the allocation up to the end addressable memory was
non-spaces, this loop could cause a segmentation fault.

Avoid that by ensuring we stop when we see a NUL.

toke.c

diff --git a/toke.c b/toke.c
index 4a67857..c3d3c97 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1694,7 +1694,7 @@ S_incline(pTHX_ const char *s)
     }
     else {
        t = s;
-       while (!isSPACE(*t))
+       while (*t && !isSPACE(*t))
            t++;
        e = t;
     }