git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: fix 'Use of uninitialized value' error in href()

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Jul 31, 2009, 06:48 UTC
Message-ID
<1249022929-21037-1-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<200907310824.42953.jnareb@gmail.com>

Equality between file_parent and file_name was being checked without a preliminary check for existence of the parameters.

Fix by wrapping the equality check in appropriate if (defined ...), rearranging the lines to prevent excessive length.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

The funny thing is that I seem to get the error for something as simple as a commit view (_any_ commit view, for the matter), but I wasn't able to reproduce it from the shell, which is why I'm not adding a testcase.

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7fbd5ff..37120a3 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -940,10 +940,13 @@ sub href {
 			if (defined $params{'hash_parent_base'}) {
 				$href .= esc_url($params{'hash_parent_base'});
 				# skip the file_parent if it's the same as the file_name
-				delete $params{'file_parent'} if $params{'file_parent'} eq $params{'file_name'};
-				if (defined $params{'file_parent'} && $params{'file_parent'} !~ /\.\./) {
-					$href .= ":/".esc_url($params{'file_parent'});
-					delete $params{'file_parent'};
+				if (defined $params{'file_parent'}) {
+					if (defined $params{'file_name'} && $params{'file_parent'} eq $params{'file_name'}) {
+						delete $params{'file_parent'};
+					} elsif ($params{'file_parent'} !~ /\.\./) {
+						$href .= ":/".esc_url($params{'file_parent'});
+						delete $params{'file_parent'};
+					}
 				}
 				$href .= "..";
 				delete $params{'hash_parent'};
-- 
1.6.3.rc1.192.gdbfcb
Previous: Jakub NarebskiNext: Jakub Narebski
Message 5 of 9 in “gitweb: suppress 'Use of uninitialized value' error”
  1. gitweb: suppress 'Use of uninitialized value' errorGiuseppe Bilotta, Jul 30, 2009
  2. Jakub NarebskiJul 30, 2009
  3. Giuseppe BilottaJul 31, 2009
  4. Jakub NarebskiJul 31, 2009
  5. gitweb: fix 'Use of uninitialized value' error in href()Giuseppe Bilotta, Jul 31, 2009
  6. Jakub NarebskiJul 31, 2009
  7. Giuseppe BilottaJul 31, 2009
  8. Junio C HamanoJul 31, 2009
  9. Junio C HamanoAug 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.