This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix SEGV with eval("package Foo {")
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index 691ae94..dcb6114 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -667,9 +667,16 @@ package :  PACKAGE WORD WORD ';'
 
 package_block: PACKAGE WORD WORD '{' remember
                        {
+                         int save_3_latefree = $3->op_latefree;
+                         $3->op_latefree = 1;
                          package($3);
-                         if ($2)
+                         $3->op_latefree = save_3_latefree;
+                         if ($2) {
+                             int save_2_latefree = $2->op_latefree;
+                             $2->op_latefree = 1;
                              package_version($2);
+                             $2->op_latefree = save_2_latefree;
+                         }
                        }
                    lineseq '}'
                        { if (PL_parser->copline > (line_t)IVAL($4))
@@ -677,6 +684,9 @@ package_block:      PACKAGE WORD WORD '{' remember
                          $$ = block_end($5, $7);
                          TOKEN_GETMAD($4,$$,'{');
                          TOKEN_GETMAD($8,$$,'}');
+                         op_free($3);
+                         if ($2)
+                             op_free($2);
                        }
        ;