From c2971ad32cab8404e7fbea8eb0f7eb2f7f6f8fbf Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Tue, 7 Apr 2020 20:56:42 +0200 Subject: [PATCH] Fix warning: undefined value as an ARRAY reference at line 2619. Thanks to Jason Dishop for the report. --- sendmailanalyzer | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sendmailanalyzer b/sendmailanalyzer index 54e18cf..ffff563 100755 --- a/sendmailanalyzer +++ b/sendmailanalyzer @@ -2610,17 +2610,23 @@ sub flush_data delete $TO{$host}{$id}; next; } - for (my $i = 0; $i <= $#{$TO{$host}{$id}{date}}; $i++) { - # Key: year/month/day, Format: Hour:Id:Rcpt:Relay:Status - next if ($TO{$host}{$id}{date}[$i] !~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/); - $rcpts{"$1/$2/$3"} .= "$4$5$6" . ':' . $id . ':' . $TO{$host}{$id}{to}[$i] . ':' . $TO{$host}{$id}{relay}[$i] . ':' . $TO{$host}{$id}{status}[$i] . "\n"; - $nobj++; + if (exists $TO{$host}{$id}{date}) + { + for (my $i = 0; $i <= $#{$TO{$host}{$id}{date}}; $i++) { + # Key: year/month/day, Format: Hour:Id:Rcpt:Relay:Status + next if ($TO{$host}{$id}{date}[$i] !~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/); + $rcpts{"$1/$2/$3"} .= "$4$5$6" . ':' . $id . ':' . $TO{$host}{$id}{to}[$i] . ':' . $TO{$host}{$id}{relay}[$i] . ':' . $TO{$host}{$id}{status}[$i] . "\n"; + $nobj++; + } } - for (my $i = 0; $i <= $#{$TO{$host}{$id}{queue_date}}; $i++) { - # Key: year/month/day, Format: Hour:Id:Rcpt:Relay:Status - next if ($TO{$host}{$id}{queue_date}[$i] !~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/); - $rcpts{"$1/$2/$3"} .= "$4$5$6" . ':' . $id . ':' . $TO{$host}{$id}{queue_to}[$i] . ":none:Queued\n"; - $nobj++; + if (exists $TO{$host}{$id}{queue_date}) + { + for (my $i = 0; $i <= $#{$TO{$host}{$id}{queue_date}}; $i++) { + # Key: year/month/day, Format: Hour:Id:Rcpt:Relay:Status + next if ($TO{$host}{$id}{queue_date}[$i] !~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/); + $rcpts{"$1/$2/$3"} .= "$4$5$6" . ':' . $id . ':' . $TO{$host}{$id}{queue_to}[$i] . ":none:Queued\n"; + $nobj++; + } } # Complete Spam information if (exists $SPAM{$host}{$id} && !exists $SPAM{$host}{$id}{to}) {