This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
stop %^H pointing to being-freed hash; #112326
authorDavid Mitchell <davem@iabyn.com>
Wed, 11 Apr 2012 12:37:09 +0000 (13:37 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 11 Apr 2012 13:20:53 +0000 (14:20 +0100)
commit2653c1e3b10f71430de1ab8ab0417ca5b048ab19
tree6bd9a1c4a68d9cc5a551584aa3255afd35a3f952
parent629e8f5e3a9b318b663e6fbb0025a6b0c03deffe
stop %^H pointing to being-freed hash; #112326

The leave_scope() action SAVEt_HINTS does the following to
GvHV(PL_hintgv): first it SvREFCNT_dec()'s it, then sets it to NULL.
If the current %^H contains a destructor, then that will be
executed while %^H still points to the hash being freed.
This can cause bad things to happen, like iterating over the hash being
freed.

Instead, setGvHV(PL_hintgv) to NULL first, *then* free the hash.
scope.c
t/comp/hints.t