diff options
author | David Mitchell <davem@iabyn.com> | 2011-05-24 17:08:51 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2011-05-29 20:21:52 +0100 |
commit | 3808a68376b13a13745f22f7454ecf5e673ad24f (patch) | |
tree | f95fb958d4247f60b5a662e0fb571b6cbf33dbaf /Makefile.SH | |
parent | 554bc0f461f4e9d7662d10d7bd81d8c36ba36776 (diff) | |
download | perl-3808a68376b13a13745f22f7454ecf5e673ad24f.tar.gz |
RT #91032: formline: bugs with non-string formats
When the format SV used by formline isn't a simple POK (such as
ties, overloads, or stringified refs), many many things go wrong,
and SEGVs ensue.
Originally, pp_formline forced the SV to a PV, and then assumed it could
rely on the resulting SvPVX value. Recent commits fixed this to
skip the force (good), but then broke things such as:
* in the absence of POK or pPOK, $^A was grown by 0 bytes rather than the
length of the format, so the buffer overran;
* the compiled format stored indexes into the original format string
to refer to chunks of content text and the like. If there's no real
SvPVX around, that's bad.
* Stuff like tie and overload could return different format strings on
each get, but the format would not be re-compiled (but would index into
the new string anyway)
Also, the format compiler would convert strings like '~~' into blanks
in the original format SV.
The easiest way to fix all these is to save a copy of the original string
at the time it is compiled. This can conveniently be stored in the mg_obj
slot of the fm magic (the compiled format already goes in mg_ptr).
This way we're always guaranteed to have an unadulterated copy of the
string to mess with.
Also, the ~~ self-modification now happens to the copy rather than the
original.
Now each time formline is called, we also compare the current value of the
SV with the stored copy, and if it's changed (e.g. tie with a FETCH that
returns different values each time), then we recompile.
Note that the recompile test is currently defeated by the ~~ modification,
so re-compiles unnecessarily (but safely) in that case. A fix for that is
coming next.
Diffstat (limited to 'Makefile.SH')
0 files changed, 0 insertions, 0 deletions