develooper Front page | perl.perl5.porters | Postings from December 2003

[PATCH] Re: [perl #24704] Regex replace looses chars

Thread Previous | Thread Next
From:
Marty Pauley
Date:
December 21, 2003 14:40
Subject:
[PATCH] Re: [perl #24704] Regex replace looses chars
Message ID:
20031221223950.GH31758@soto.kasei.com
The problem here is that the subst context sb_s is pointing to parts of
the PV, but the PVIV upgrade moves the text in the PV, so the subst
context sb_s is still pointing to where it used to be.

A simple (but not great) fix is to remove the OOK before we mess with
the sv.


--- pp_hot.c.orig       2003-12-21 03:35:10.000000000 +0000
+++ pp_hot.c    2003-12-21 22:32:56.000000000 +0000
@@ -2172,6 +2172,7 @@
        RETURN;
     }

+    SvOOK_off(TARG);
     if (CALLREGEXEC(aTHX_ rx, s, strend, orig, 0, TARG, NULL,
                    r_flags | REXEC_CHECKED))
     {



If you're feeling paranoid, a safer place to unOOK is much closer to the
start of pp_subst, just before we take the first pointer to the inside
of the PV.


--- pp_hot.c.orig       2003-12-21 03:35:10.000000000 +0000
+++ pp_hot.c    2003-12-21 22:34:10.000000000 +0000
@@ -1981,6 +1981,7 @@
        DIE(aTHX_ PL_no_modify);
     PUTBACK;

+    SvOOK_off(TARG);
     s = SvPV(TARG, len);
     if (!SvPOKp(TARG) || SvTYPE(TARG) == SVt_PVGV)
        force_on_match = 1;


-- 
Marty

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About