[perl #97988] Nullify PL_last_in_gv when unglobbed
authorFather Chrysostomos <sprout@cpan.org>
Sun, 18 Dec 2011 03:22:51 +0000 (19:22 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 18 Dec 2011 07:19:03 +0000 (23:19 -0800)
commit69930016894689da4e8234c429d5ef26b311e7ec
tree850166ef2a979490826efdb5cfd42a12646854c4
parentd6ec5f13c8daa49c1550a4fa54a8410f913203fd
[perl #97988] Nullify PL_last_in_gv when unglobbed

Code like this can cause PL_last_in_gv to point to a coercible glob:

    $f{g} = *STDOUT;
    readline $f{g};

If $f{g} is then modified such that it is no longer a glob,
PL_last_in_gv ends up pointing to a non-glob:

    $f{g} = 3;

If $f{g} is freed now, the PL_last_in_gv-nulling code in sv_clear will
be skipped, as it only applies to globs.

    undef %f; # now PL_last_in_gv points to a freed scalar

The resulting freed scalar can be reused by another handle,

    *{"foom"} = *other;

causing tell() with no arguments to return the position on *other,
even though *other was no the last handle read from.

This commit fixes it by nulling PL_last_in_gv when a coercible glob
is coerced.
sv.c
t/op/readline.t