regcomp.c: Really stop regexp-to-pv assignment from leaking
authorFather Chrysostomos <sprout@cpan.org>
Mon, 29 Oct 2012 07:01:02 +0000 (00:01 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 30 Oct 2012 19:36:04 +0000 (12:36 -0700)
edd9fea2b8 was not enough.  A scalar may hold a PV even with the
SvPOKp flag off:

$ ./perl -Ilib -e 'warn $$; while(1){ $x = "a"; $x = 1; $x = ${qr//}}'

regcomp.c

index a0794b8..2007037 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -14179,7 +14179,7 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x, REGEXP *rx)
     if (!ret_x)
        ret_x = (REGEXP*) newSV_type(SVt_REGEXP);
     else {
-       if (SvPOKp(ret_x)) SvPV_free(ret_x);
+       SvPV_free(ret_x);
        SvOK_off((SV *)ret_x);
     }
     /* This ensures that SvTHINKFIRST(sv) is true, and hence that