diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-07-11 13:13:58 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-07-11 17:47:53 -0700 |
commit | 4e917a04b786fbe31ab3ff95fbef9b0c7e6637c0 (patch) | |
tree | 92f2b272a92521aad344d612c0a8904d218ef813 /toke.c | |
parent | f556af6c048b2769e0a588d55ef54f5949171836 (diff) | |
download | perl-4e917a04b786fbe31ab3ff95fbef9b0c7e6637c0.tar.gz |
[perl #118627] Don’t do COW when creating ${"_<-e"}[0]
The lexer does not expect PL_linestr (an SV holding the current line
of Perl code being parsed) to do copy-on-write. It expects to be able
to manipulate that SV to its hearts content with impunity. The one
piece of code that can cause it to do that is S_update_debugger_info,
when called with a SV for the first argument. The only time it is
called that way is for line 0 of the main script, containing state-
ments generated from command line arguments (e.g., ‘use strict’ from
‘-Mstrict’), and it is called with PL_linestr as its argument.
If ${"_<-e"}[0] ends up sharing the buffer with PL_linestr, bad things
will happen, as the lexer is going to continue to modify that buffer.
Usually we get this:
$ ./perl -It/lib -d:switchd_empty -e'print @{"_<-e"}' |less
^@se Devel::switchd_empty;
print @{"_<-e"}
So force S_update_debugger_info to do a non-COW copy.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1919,7 +1919,7 @@ S_update_debugger_info(pTHX_ SV *orig_sv, const char *const buf, STRLEN len) if (av) { SV * const sv = newSV_type(SVt_PVMG); if (orig_sv) - sv_setsv(sv, orig_sv); + sv_setsv_flags(sv, orig_sv, 0); /* no cow */ else sv_setpvn(sv, buf, len); (void)SvIOK_on(sv); |