X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp.c;h=d63f03980906503491982cb9fc607a0b69f214e3;hb=c696a6a43b0b5a16f820f8a91db4e187fc9ac45b;hp=f9f9e7b82d917706718ee04ba1590ffca3be1223;hpb=a0cec76945276a0895c829a391529265d9b76bc0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp.c b/pp.c index f9f9e7b..d63f039 100644 --- a/pp.c +++ b/pp.c @@ -639,13 +639,22 @@ PP(pp_study) if (SvSCREAM(sv)) RETPUSHYES; } - else { - if (PL_lastscream) { - SvSCREAM_off(PL_lastscream); - SvREFCNT_dec(PL_lastscream); - } - PL_lastscream = SvREFCNT_inc(sv); + s = (unsigned char*)(SvPV(sv, len)); + pos = len; + if (pos <= 0 || !SvPOK(sv)) { + /* No point in studying a zero length string, and not safe to study + anything that doesn't appear to be a simple scalar (and hence might + change between now and when the regexp engine runs without our set + magic ever running) such as a reference to an object with overloaded + stringification. */ + RETPUSHNO; + } + + if (PL_lastscream) { + SvSCREAM_off(PL_lastscream); + SvREFCNT_dec(PL_lastscream); } + PL_lastscream = SvREFCNT_inc(sv); s = (unsigned char*)(SvPV(sv, len)); pos = len; @@ -4254,7 +4263,8 @@ PP(pp_reverse) sv_setsv(TARG, (SP > MARK) ? *SP : (padoff_du = find_rundefsvoffset(), - (padoff_du == NOT_IN_PAD || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR) + (padoff_du == NOT_IN_PAD + || PAD_COMPNAME_FLAGS_isOUR(padoff_du)) ? DEFSV : PAD_SVl(padoff_du))); up = SvPV_force(TARG, len); if (len > 1) {