From: Jarkko Hietaniemi Date: Sat, 18 Aug 2001 03:22:24 +0000 (+0000) Subject: (Retracted by #11714) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=af903f693e49116b2e364fd529103fa436976640;p=p5sagit%2Fp5-mst-13.2.git (Retracted by #11714) Okay analysis, debatable fix. (The fix will inc the refcount of all temporary match objects, like for example tied(%h) =~ /^.../ from Tie/RefHash.t, which will then cause griping at untie() time ("inner references remain"). Fix for ID 20010407.006: PL_reg_sv got wiped out by freetemps if the match target was a temporary (like function_call() =~ /.../), which in turn meant that the $1 et al stopped working if they had UTF-8 in them. Therefore bump up the refcount of PL_reg_sv. p4raw-id: //depot/perl@11712 --- diff --git a/pp_hot.c b/pp_hot.c index 0f4a693..c0c6fe8 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1222,7 +1222,7 @@ PP(pp_match) TARG = DEFSV; EXTEND(SP,1); } - PL_reg_sv = TARG; + PL_reg_sv = SvREFCNT_inc(TARG); PUTBACK; /* EVAL blocks need stack_sp. */ s = SvPV(TARG, len); strend = s + len; @@ -1909,7 +1909,7 @@ PP(pp_subst) TARG = DEFSV; EXTEND(SP,1); } - PL_reg_sv = TARG; + PL_reg_sv = SvREFCNT_inc(TARG); do_utf8 = DO_UTF8(PL_reg_sv); if (SvFAKE(TARG) && SvREADONLY(TARG)) sv_force_normal(TARG); diff --git a/t/op/pat.t b/t/op/pat.t index d2d3205..478e299 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -6,7 +6,7 @@ $| = 1; -print "1..684\n"; +print "1..686\n"; BEGIN { chdir 't' if -d 't'; @@ -1987,3 +1987,22 @@ print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r"; $c = pos; print "$a $b $c" eq 'ba:ba ad:ae 10' ? "ok 684\n" : "not ok 684\t# $a $b $c\n"; } + +{ + package ID_20010407_006; + + sub x { + "a\x{1234}"; + } + + my $x = x; + my $y; + + $x =~ /(..)/; $y = $1; + print "not " unless length($y) == 2 && $y eq $x; + print "ok 685\n" if length($y) == 2; + + x =~ /(..)/; $y = $1; + print "not " unless length($y) == 2 && $y eq $x; + print "ok 686\n"; +}