This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
For cases FF_LINESNGL and FF_LINEGLOB in pp_formline, take great care
authorNicholas Clark <nick@ccl4.org>
Sun, 13 Jul 2008 21:02:43 +0000 (21:02 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 13 Jul 2008 21:02:43 +0000 (21:02 +0000)
commite8e72d41921b8365de491c29d17ce128c04ed94d
tree78a93dd18de7a3877117815965bb789c5f85d9cd
parent6c65d5f9331797a0b303b34e8a76d4c0ea75e4d0
For cases FF_LINESNGL and FF_LINEGLOB in pp_formline, take great care
to call get magic exactly once. This doesn't just avoid logical errors
with tied variables, it actually avoids panics (or worse) because a
pointer is retained to the string returned by the (first) call to
SvPV_const() for a future sv_chop(), and any future call to get magic
can invalidate the buffer that that pointer points to.
Also this removes the original crazy code that would set then reset the
length of a scalar, so as to only copy an initial portion of it, and
also copy the entire scalar including trailing newline (which might
require allocating more memory), only to immediately remove the newline
from the copy by reducing the length by one.

p4raw-id: //depot/perl@34139
pp_ctl.c
t/op/write.t