File: 02-undef

package info (click to toggle)
libproc-pid-file-perl 1.27-4.2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 140 kB
  • sloc: perl: 485; makefile: 39
file content (14 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Description: fix for undef input into regex match
Author: Alexander Zangerl <az@debian.org>
--- a/File.pm
+++ b/File.pm
@@ -285,7 +285,8 @@ sub read {
 		|| die qq/Cannot open pid file "$self->{path}": $!\n/;
 	flock($fh, LOCK_EX | LOCK_NB)
         || die qq/pid "$self->{path}" already locked: $!\n/;
-	my ($pid) = <$fh> =~ /^(\d+)/;
+	my $maybe = <$fh>;
+	my ($pid) = $maybe =~ /^(\d+)/ if (defined $maybe);
 	close $fh if @_ == 1;
 
 	$self->debug("read(\"$self->{path}\") = " . ($pid || ""));