X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-File-KDBX;a=blobdiff_plain;f=lib%2FFile%2FKDBX%2FKey.pm;h=8a5796568bd9c2c2d03a6d97723826a5245e4c02;hp=8fdb0ff9a88b7a43b483ff3f5ba50b1e48b585a1;hb=81604125cc023132207802b4ae0ab4cea12c17fd;hpb=cfe6ddf632ec8f9ce9569fbf4c7e759160ba3419 diff --git a/lib/File/KDBX/Key.pm b/lib/File/KDBX/Key.pm index 8fdb0ff..8a57965 100644 --- a/lib/File/KDBX/Key.pm +++ b/lib/File/KDBX/Key.pm @@ -8,14 +8,15 @@ use Devel::GlobalDestruction; use File::KDBX::Error; use File::KDBX::Safe; use File::KDBX::Util qw(erase); +use Hash::Util::FieldHash qw(fieldhashes); use Module::Load; use Ref::Util qw(is_arrayref is_coderef is_hashref is_ref is_scalarref); -use Scalar::Util qw(blessed openhandle refaddr); +use Scalar::Util qw(blessed openhandle); use namespace::clean; our $VERSION = '999.999'; # VERSION -my %SAFE; +fieldhashes \my %SAFE; =method new @@ -55,7 +56,10 @@ sub new { return $self; } -sub DESTROY { !in_global_destruction and do { $_[0]->_clear_raw_key; erase \$_[0]->{primitive} } } +sub DESTROY { + local ($., $@, $!, $^E, $?); + !in_global_destruction and do { $_[0]->_clear_raw_key; eval { erase \$_[0]->{primitive} } } +} =method init @@ -191,10 +195,10 @@ Get whether or not the key's raw secret is currently in memory protection. =cut -sub is_hidden { !!$SAFE{refaddr($_[0])} } +sub is_hidden { !!$SAFE{$_[0]} } -sub _safe { $SAFE{refaddr($_[0])} } -sub _new_safe { $SAFE{refaddr($_[0])} = File::KDBX::Safe->new } +sub _safe { $SAFE{$_[0]} } +sub _new_safe { $SAFE{$_[0]} = File::KDBX::Safe->new } 1; __END__