diff options
author | Vincent Pit <perl@profvince.com> | 2015-08-28 14:17:00 -0300 |
---|---|---|
committer | Vincent Pit <perl@profvince.com> | 2015-10-08 12:34:22 -0300 |
commit | 0ee3fa26f660ac426e3e082f77d806c9d1471f93 (patch) | |
tree | 87c3ba9722e26787eac699bfd1f592f74e43ca06 /pp_sys.c | |
parent | fa7a1e491ab222c171fed6ca536cf7483a165414 (diff) | |
download | perl-0ee3fa26f660ac426e3e082f77d806c9d1471f93.tar.gz |
Properly duplicate PerlIO::encoding objects
PerlIO::encoding objects are usually initialized by calling Perl methods,
essentially from the pushed() and getarg() callbacks. During cloning, the
PerlIO API will by default call these methods to initialize the duplicate
struct when the PerlIOBase parent struct is itself duplicated. This does
not behave so well because the perl interpreter is not ready to call
methods at this point, for the stacks are not set up yet.
The proper way to duplicate the PerlIO::encoding object is to call sv_dup()
on its members from the dup() PerlIO callback. So the only catch is to make
the getarg() and pushed() calls implied by the duplication of the underlying
PerlIOBase object aware that they are called during cloning, and make them
wait that the control flow returns to the dup() callback. Fortunately,
getarg() knows since its param argument is then non-null, and its return
value is passed immediately to pushed(), so it is enough to tag this
returned value with a custom magic so that pushed() can see it is being
called during cloning.
This fixes [RT #31923].
Diffstat (limited to 'pp_sys.c')
0 files changed, 0 insertions, 0 deletions