If an interpolated string looks as though it contains a regexp code
block, the regexp compiler will evaluate it inside qr'...' and then
extract the code blocks from the resulting regexp object.
If it turned out to be a false positive (e.g., "[(?{})]"), then
the code to handle this returned without freeing the temporary reg-
exp object.
int i1 = 0, i2 = 0;
if (!r2->num_code_blocks) /* we guessed wrong */
+ {
+ SvREFCNT_dec(qr);
return 1;
+ }
Newx(new_block,
r1->num_code_blocks + r2->num_code_blocks,
use Config;
-plan tests => 38;
+plan tests => 40;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
my @a;
eval { push @a, $die_on_fetch };
}, 'pushing exploding scalar does not leak');
+
+
+# Run-time regexp code blocks
+{
+ my @tests = ('[(?{})]');
+ for my $t (@tests) {
+ leak(2, 0, sub {
+ / $t/;
+ }, "/ \$x/ where \$x is $t does not leak");
+ leak(2, 0, sub {
+ /(?{})$t/;
+ }, "/(?{})\$x/ where \$x is $t does not leak");
+ }
+}