Craig A. Berry [Sat, 25 Jul 2009 19:06:34 +0000 (14:06 -0500)]
If the op inside of a (?{ }) construct is another regex, the two
regexen end up corrupting each others' end-of-string markers,
resulting in various pathologies including access violations,
stack corruptions, and memory use growing without bound.
The change here is intended to be a relatively safe, cheap way to
prevent memory errors and makes no attempt to save and restore
other aspects of regex state; i.e., general purpose reentrancy
for the regex engine is still a TODO.
OP_4tree * const oop = PL_op;
COP * const ocurcop = PL_curcop;
PAD *old_comppad;
+ char *saved_regeol = PL_regeol;
n = ARG(scan);
PL_op = (OP_4tree*)rexi->data->data[n];
PL_op = oop;
PAD_RESTORE_LOCAL(old_comppad);
PL_curcop = ocurcop;
+ PL_regeol = saved_regeol;
if (!logical) {
/* /(?{...})/ */
sv_setsv(save_scalar(PL_replgv), ret);