From: Dave Mitchell Date: Fri, 14 Sep 2007 21:59:59 +0000 (+0000) Subject: [perl #45337] utf8 + "[a]a{2}" + /$.../ = panic: sv_len_utf8 cache X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bd94e8870784246bb7caab6a441839b05491de37;p=p5sagit%2Fp5-mst-13.2.git [perl #45337] utf8 + "[a]a{2}" + /$.../ = panic: sv_len_utf8 cache when shrinking an SV, shrink the sv_len_utf8 cache too! p4raw-id: //depot/perl@31867 --- diff --git a/regcomp.c b/regcomp.c index 358ac8e..441d762 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3297,7 +3297,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL; if (mg && mg->mg_len >= 0) - mg->mg_len += CHR_SVLEN(last_str); + mg->mg_len += CHR_SVLEN(last_str) - l; } data->last_end += l * (mincount - 1); } diff --git a/t/op/pat.t b/t/op/pat.t index 536c6cd..00d00e7 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -4524,10 +4524,19 @@ ok($@=~/\QSequence \k... not terminated in regex;\E/); iseq($_,"!Bang!1!Bang!2!Bang!3!Bang!"); } +# [perl #45337] utf8 + "[a]a{2}" + /$.../ = panic: sv_len_utf8 cache + +{ + local ${^UTF8CACHE} = -1; + my $s="[a]a{2}"; + utf8::upgrade $s; + ok("aaa" =~ /$s/, "#45337"); +} + # Put new tests above the dotted line about a page above this comment iseq(0+$::test,$::TestCount,"Got the right number of tests!"); # Don't forget to update this! BEGIN { - $::TestCount = 1963; + $::TestCount = 1964; print "1..$::TestCount\n"; }