Re: [ID 20010422.005] perl -e '{s//${}/; //}' # segfaults on FreeBSD
Spider Boardman [Mon, 28 May 2001 06:39:12 +0000 (02:39 -0400)]
Message-Id: <200105281039.GAA03962@Orb.Nashua.NH.US>

p4raw-id: //depot/perl@10250

toke.c

diff --git a/toke.c b/toke.c
index 0781a9a..febb820 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1043,6 +1043,7 @@ S_sublex_push(pTHX)
     SAVEI32(PL_lex_inwhat);
     SAVECOPLINE(PL_curcop);
     SAVEPPTR(PL_bufptr);
+    SAVEPPTR(PL_bufend);
     SAVEPPTR(PL_oldbufptr);
     SAVEPPTR(PL_oldoldbufptr);
     SAVEPPTR(PL_last_lop);
@@ -3227,8 +3228,16 @@ Perl_yylex(pTHX)
                else
                    PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR;
                s = skipspace(s);
-               if (*s == '}')
+               if (*s == '}') {
+                   if (PL_expect == XREF && PL_lex_state == LEX_INTERPNORMAL) {
+                       PL_expect = XTERM;
+                       /* This hack is to get the ${} in the message. */
+                       PL_bufptr = s+1;
+                       yyerror("syntax error");
+                       break;
+                   }
                    OPERATOR(HASHBRACK);
+               }
                /* This hack serves to disambiguate a pair of curlies
                 * as being a block or an anon hash.  Normally, expectation
                 * determines that, but in cases where we're not in a