]> Lady’s Gitweb - Gitweb/commitdiff
fix: Use of uninitialized value
authorKay Sievers <redacted>
Tue, 17 Jan 2006 02:50:20 +0000 (03:50 +0100)
committerKay Sievers <redacted>
Tue, 17 Jan 2006 02:50:20 +0000 (03:50 +0100)
The subroutine did not check the case where HEAD does not verify.

Patch from Junio C Hamano <redacted>

gitweb.cgi

index 361f88e30fc8862341ad26ba20bc2e5cb8db7a4190ddd7e0f5c10b29818210f4..b4baa9be8802e642445f167614bf9e506dfa2c9cf91e173fc213a2fd8d6494d4 100755 (executable)
@@ -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;
 }
 
This page took 0.204 seconds and 4 git commands to generate.