develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123712] Segmentation fault in S_scan_heredoc()

Thread Previous
From:
Hugo van der Sanden via RT
Date:
February 10, 2015 18:15
Subject:
[perl #123712] Segmentation fault in S_scan_heredoc()
Message ID:
rt-4.0.18-577-1423592107-54.123712-15-0@perl.org
On Sun Feb 01 14:41:10 2015, sprout wrote:
> On Sun Feb 01 14:38:39 2015, sprout wrote:

> > This is likely related to #123617, though it appears to be more
> > recent.  I’m running a bisect.
> 
> 4efe39d21e072e88e12e308ed1f068461f8ef778 is the first bad commit
> commit 4efe39d21e072e88e12e308ed1f068461f8ef778
> Author: Father Chrysostomos <sprout@cpan.org>
> Date:   Wed Aug 29 22:07:18 2012 -0700
> 
>     toke.c:scan_heredoc: Merge similar code
>     
>     The code for looking in outer lexing scopes was mostly identical to
>     the code for looking in PL_linestr.

The below is one aspect changed from the original, and is enough to make it survive (and pass tests); I'm not sure why reality doesn't match the various comments though (so that we're here with !infile and !PL_lex_inwhat, and it isn't an eval, and doesn't have a newline), so I'm not sure how to fix those.

Hugo

diff --git a/toke.c b/toke.c
index 24b5ed0..13f30e7 100644
--- a/toke.c
+++ b/toke.c
@@ -9275,7 +9275,8 @@ S_scan_heredoc(pTHX_ char *s)
          }
        else {  /* eval */
            s = (char*)memchr((void*)s, '\n', PL_bufend - s);
-           assert(s);
+           if (!s)
+                s = PL_bufend;
        }
        linestr = shared->ls_linestr;
        bufend = SvEND(linestr);



---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123712

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About