diff options
author | Ben Morrow <ben@morrow.me.uk> | 2009-10-22 23:17:51 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-10-22 23:17:51 +0200 |
commit | f0826785082983bd9b5ba16476c6867f3b390fb9 (patch) | |
tree | f9b18510046eacdecbfaca3f2cefbd5ca2865b83 /regcomp.c | |
parent | dc35ab6e9838269debf9973a573bbd31031f3f31 (diff) | |
download | perl-f0826785082983bd9b5ba16476c6867f3b390fb9.tar.gz |
RT#69616: regexp SVs lose regexpness in assignment
It uses reg_temp_copy to copy the REGEXP onto the destination SV without
needing to copy the underlying pattern structure. This means changing
the prototype of reg_temp_copy, so it can copy onto a passed-in SV, but
it isn't API (and probably shouldn't be exported) so I don't think this
is a problem.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -9442,15 +9442,18 @@ Perl_pregfree2(pTHX_ REGEXP *rx) REGEXP * -Perl_reg_temp_copy (pTHX_ REGEXP *rx) +Perl_reg_temp_copy (pTHX_ REGEXP *ret_x, REGEXP *rx) { - REGEXP *ret_x = (REGEXP*) newSV_type(SVt_REGEXP); - struct regexp *ret = (struct regexp *)SvANY(ret_x); + struct regexp *ret; struct regexp *const r = (struct regexp *)SvANY(rx); register const I32 npar = r->nparens+1; PERL_ARGS_ASSERT_REG_TEMP_COPY; + if (!ret_x) + ret_x = (REGEXP*) newSV_type(SVt_REGEXP); + ret = (struct regexp *)SvANY(ret_x); + (void)ReREFCNT_inc(rx); /* We can take advantage of the existing "copied buffer" mechanism in SVs by pointing directly at the buffer, but flagging that the allocated |