Skip to content

Commit a9eb90a

Browse files
oyvholmgitster
authored andcommitted
gitweb: squelch "uninitialized value" warning
git_object() chomps $type that is read from "cat-file -t", but it does so before checking if $type is defined, resulting in a Perl warning in the server error log: gitweb.cgi: Use of uninitialized value $type in scalar chomp at [...]/gitweb.cgi line 7579., referer: [...] when trying to access a non-existing commit, for example: http://HOST/?p=PROJECT.git;a=commit;h=NON_EXISTING_COMMIT Check the value in $type before chomping. This will cause us to call href with its action parameter set to undef when formulating the URL to redirect to, but that is harmless, as the function treats a parameter that set to undef as if it does not exist. Signed-off-by: Øyvind A. Holm <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a2558fb commit a9eb90a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7576,7 +7576,7 @@ sub git_object {
75767576
git_cmd(), 'cat-file', '-t', $object_id) . ' 2> /dev/null'
75777577
or die_error(404, "Object does not exist");
75787578
$type = <$fd>;
7579-
chomp $type;
7579+
defined $type && chomp $type;
75807580
close $fd
75817581
or die_error(404, "Object does not exist");
75827582

0 commit comments

Comments
 (0)