This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #123843] fix SEGV reading data->flags
authorHugo van der Sanden <hv@crypt.org>
Sun, 15 Feb 2015 11:44:00 +0000 (11:44 +0000)
committerHugo van der Sanden <hv@crypt.org>
Sun, 15 Feb 2015 23:21:47 +0000 (23:21 +0000)
This could be triggered by trying to compile eg 'qr{x+(y(?0))*}'.

regcomp.c
t/re/pat.t

index 767f497..51c778d 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4386,7 +4386,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
                     ( flags & SCF_IN_DEFINE )
                     ||
                     (
                     ( flags & SCF_IN_DEFINE )
                     ||
                     (
-                        (is_inf_internal || is_inf || data->flags & SF_IS_INF)
+                        (is_inf_internal || is_inf || (data && data->flags & SF_IS_INF))
                         &&
                         ( (flags & (SCF_DO_STCLASS | SCF_DO_SUBSTR)) == 0 )
                     )
                         &&
                         ( (flags & (SCF_DO_STCLASS | SCF_DO_SUBSTR)) == 0 )
                     )
index ddfaebc..137a049 100644 (file)
@@ -22,7 +22,7 @@ BEGIN {
     skip_all_without_unicode_tables();
 }
 
     skip_all_without_unicode_tables();
 }
 
-plan tests => 770;  # Update this when adding/deleting tests.
+plan tests => 772;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
 
 run_tests() unless caller;
 
@@ -1676,6 +1676,14 @@ EOP
             fresh_perl_is($code, "No infinite loop here!", {},
                 "test that we handle things like m/\\888888888/ without infinite loops" );
         }
             fresh_perl_is($code, "No infinite loop here!", {},
                 "test that we handle things like m/\\888888888/ without infinite loops" );
         }
+
+       {
+               # [perl #123843] hits SEGV trying to compile this pattern
+               my $match;
+               eval q{ ($match) = ("xxyxxyxy" =~ m{(x+(y(?1))*)}) };
+               ok(1, "compiled GOSUB in CURLYM ok");
+               is($match, 'xxyxxyx', "matched GOSUB in CURLYM");
+       }
 } # End of sub run_tests
 
 1;
 } # End of sub run_tests
 
 1;