return FALSE;
}
+static Perl_ophook_t old_ophook;
+
+static void
+glob_ophook(pTHX_ OP *o)
+{
+ dMY_CXT;
+ if (MY_CXT.x_GLOB_ENTRIES
+ && (o->op_type == OP_GLOB || o->op_type == OP_ENTERSUB))
+ hv_delete(MY_CXT.x_GLOB_ENTRIES, (char *)&o, sizeof(OP *),
+ G_DISCARD);
+ if (old_ophook) old_ophook(aTHX_ o);
+}
+
MODULE = File::Glob PACKAGE = File::Glob
int
dMY_CXT;
MY_CXT.x_GLOB_ENTRIES = NULL;
}
+ OP_REFCNT_LOCK;
+ old_ophook = PL_opfreehook;
+ PL_opfreehook = glob_ophook;
+ OP_REFCNT_UNLOCK;
}
INCLUDE: const-xs.inc
use Config;
-plan tests => 111;
+plan tests => 112;
# 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
'vstring num overflow with fatal warnings');
eleak(2, 0, 'sub{<*>}');
+# Use a random number of ops, so that the glob op does not reuse the same
+# address each time, giving us false passes.
+leak(2, 0, sub { eval '$x+'x(rand() * 100) . '<*>'; },
+ 'freeing partly iterated glob');
eleak(2, 0, 'goto sub {}', 'goto &sub in eval');
eleak(2, 0, '() = sort { goto sub {} } 1,2', 'goto &sub in sort');