diff options
author | David Mitchell <davem@iabyn.com> | 2015-04-22 12:27:36 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-04-22 12:27:36 +0100 |
commit | a911bb254071ab7112c309e8245494c182ad9fe2 (patch) | |
tree | a5659d37c80df992bb956f0fa382227d8c132abf /pp_ctl.c | |
parent | 6b7f14c2bfbcbd1e8b2192eaba403eb382f2c0cf (diff) | |
download | perl-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.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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) |