From: Kay Sievers Date: Tue, 17 Jan 2006 02:50:20 +0000 (+0100) Subject: fix: Use of uninitialized value X-Git-Tag: v1.4.0~1^2~7 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2c5c008b462fd5d2e32318077aaa3bc4e67c84fd;p=git.git fix: Use of uninitialized value The subroutine did not check the case where HEAD does not verify. Patch from Junio C Hamano --- diff --git a/gitweb.cgi b/gitweb.cgi index 986d7dacd..cb033733b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -404,12 +404,13 @@ sub git_read_head { if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") { my $head = <$fd>; close $fd; - chomp $head; - if ($head =~ m/^[0-9a-fA-F]{40}$/) { - $retval = $head; + if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) { + $retval = $1; } } - $ENV{'GIT_DIR'} = $oENV; + if (defined $oENV) { + $ENV{'GIT_DIR'} = $oENV; + } return $retval; }