diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-02-22 22:30:19 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-02-22 22:30:19 +0000 |
commit | a4f4e9060b702ac8bd69a560b36e93c3c44a5c97 (patch) | |
tree | 4ee4a8ea31e1dfb8dd217cbb98c9bc6d1cd9e47c /pp.c | |
parent | db95ebb4c2fb7673862097bfdbfe3b9bb6d28ea5 (diff) | |
download | perl-a4f4e9060b702ac8bd69a560b36e93c3c44a5c97.tar.gz |
Avoid C<study>ing any strings that might change underneath us, such
as tied scalars and scalars with overloaded stringification.
p4raw-id: //depot/perl@27273
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -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; |