From fbab474e50997046ba37bc0a55bacecbd6641551 Mon Sep 17 00:00:00 2001 From: Nicolas R Date: Thu, 25 Apr 2024 10:41:36 +0100 Subject: [PATCH] Add protection to _replace_sub Fix #59 --- lib/Test/MockModule.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Test/MockModule.pm b/lib/Test/MockModule.pm index 7654596..b17f0ce 100644 --- a/lib/Test/MockModule.pm +++ b/lib/Test/MockModule.pm @@ -211,7 +211,7 @@ sub _replace_sub { # save a copy of all non-code slots my %slot; foreach (qw(ARRAY FORMAT HASH IO SCALAR)) { - next unless defined(my $elem = *{$symbols{$sub}}{$_}); + next unless defined $symbols{$sub} && defined(my $elem = *{$symbols{$sub}}{$_}); $slot{$_} = $elem; }