fix: Use of uninitialized value
The subroutine did not check the case where HEAD does not verify. Patch from Junio C Hamano <junkio@cox.net>
Kay Sievers committed
Jan 17, 2006 at 03:50 UTC
2c5c008b462fd5d2e32318077aaa3bc4e67c84fd
1 file changed
+5
-4
gitweb.cgi
+5
-4
@@ -404,12 +404,13 @@ sub git_read_head {
404
if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") {
405
my $head = <$fd>;
406
close $fd;
407
- chomp $head;
408
- if ($head =~ m/^[0-9a-fA-F]{40}$/) {
409
- $retval = $head;
407
+ if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
408
+ $retval = $1;
409
}
410
}
412
- $ENV{'GIT_DIR'} = $oENV;
411
+ if (defined $oENV) {
412
+ $ENV{'GIT_DIR'} = $oENV;
413
+ }
414
return $retval;
415
}
416