summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-04-22 12:27:36 +0100
committerDavid Mitchell <davem@iabyn.com>2015-04-22 12:27:36 +0100
commita911bb254071ab7112c309e8245494c182ad9fe2 (patch)
treea5659d37c80df992bb956f0fa382227d8c132abf /pp_ctl.c
parent6b7f14c2bfbcbd1e8b2192eaba403eb382f2c0cf (diff)
downloadperl-a911bb254071ab7112c309e8245494c182ad9fe2.tar.gz
s/.../$_++/ge assertion failure
The code that updated pos() on a match string assumed that it was SvPOK(). Cunning code like the following converted $_ to SvIOK only: $_ = 0; s/.?/$_++/ge;
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index c4f4d64616..335fb2101e 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -312,10 +312,16 @@ PP(pp_substcont)
SV * const sv
= (pm->op_pmflags & PMf_NONDESTRUCT) ? cx->sb_dstr : cx->sb_targ;
MAGIC *mg;
+
+ /* the string being matched against may no longer be a string,
+ * e.g. $_=0; s/.../$_++/ge */
+
+ if (!SvPOK(sv))
+ SvPV_force_nomg_nolen(sv);
+
if (!(mg = mg_find_mglob(sv))) {
mg = sv_magicext_mglob(sv);
}
- assert(SvPOK(sv));
MgBYTEPOS_set(mg, sv, SvPVX(sv), m - orig);
}
if (old != rx)