Skip to content

Commit 2c5c008

Browse files
author
Kay Sievers
committed
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>
1 parent f76ddc2 commit 2c5c008

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

gitweb.cgi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,13 @@ sub git_read_head {
404404
if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") {
405405
my $head = <$fd>;
406406
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;
410409
}
411410
}
412-
$ENV{'GIT_DIR'} = $oENV;
411+
if (defined $oENV) {
412+
$ENV{'GIT_DIR'} = $oENV;
413+
}
413414
return $retval;
414415
}
415416

0 commit comments

Comments
 (0)