diff options
author | Craig A. Berry <craigberry@mac.com> | 2009-07-25 14:06:34 -0500 |
---|---|---|
committer | Craig A. Berry <craigberry@mac.com> | 2009-07-25 14:49:12 -0500 |
commit | d80618d26460a93181dddc9ec53c3fceef864290 (patch) | |
tree | 46b47dbff549a67a4e5f36afa79983b38d440210 /regexec.c | |
parent | b7bfa855cd96849c1ce8b7e9624b69c94149aacc (diff) | |
download | perl-d80618d26460a93181dddc9ec53c3fceef864290.tar.gz |
Save and restore PL_regeol for op inside of regex (RT ##66110)
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.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -3716,6 +3716,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) 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]; @@ -3741,6 +3742,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) PL_op = oop; PAD_RESTORE_LOCAL(old_comppad); PL_curcop = ocurcop; + PL_regeol = saved_regeol; if (!logical) { /* /(?{...})/ */ sv_setsv(save_scalar(PL_replgv), ret); |