Subject: | Crash in find when there are no files found |
Date: | Fri, 23 Jun 2017 12:01:51 +0100 |
To: | "bug-SMB [...] rt.cpan.org" <bug-SMB [...] rt.cpan.org> |
From: | Daniel Beardsmore <daniel [...] trustnetworks.co.uk> |
Your example code will crash if there are no matches:
for my $file ($tree->find("*.txt")) {
printf "%-40s %s\n", $file->name, $file->mtime_string;
}
SMB Error on QueryDirectory response: c000000f
Can't use an undefined value as an ARRAY reference at /usr/local/share/perl/5.20.2/SMB/Client.pm line 305.
The SMB error is NT_STATUS_NO_SUCH_FILE. This should be suppressed in this instance as it is an expected response.
Line 305 is the last line here:
my $files = $response && $response->is_success ? $response->files : undef;
$self->process_request($connection, 'Close',
fid => $fid,
);
return wantarray ? @$files : $files;
This crash can be resolved by altering the first line to:
my $files = $response && $response->is_success ? $response->files : [];
Now you get an empty list when there are no matches.