Blame SOURCES/which-2.21-coverity.patch

7a8017
diff -up which-2.21/tilde/tilde.c.coverity2 which-2.21/tilde/tilde.c
7a8017
--- which-2.21/tilde/tilde.c.coverity2	2021-03-21 21:04:34.691775991 +0100
7a8017
+++ which-2.21/tilde/tilde.c	2021-03-21 21:13:36.853129481 +0100
7a8017
@@ -193,9 +193,8 @@ tilde_expand (string)
7a8017
      const char *string;
7a8017
 {
7a8017
   char *result;
7a8017
-  int result_size, result_index;
7a8017
+  int result_size = 0, result_index = 0;
7a8017
 
7a8017
-  result_index = result_size = 0;
7a8017
   result = strchr (string, '~');
7a8017
   if (result)
7a8017
     result = (char *)xmalloc (result_size = (strlen (string) + 16));
7a8017
@@ -271,7 +270,7 @@ isolate_tilde_prefix (fname, lenp)
7a8017
   char *ret;
7a8017
   int i;
7a8017
 
7a8017
-  ret = (char *)xmalloc (strlen (fname));
7a8017
+  ret = (char *)xmalloc (strlen (fname) + 1);
7a8017
 #if defined (__MSDOS__)
7a8017
   for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
7a8017
 #else
7a8017
diff -up which-2.21/which.c.coverity2 which-2.21/which.c
7a8017
--- which-2.21/which.c.coverity2	2021-03-21 21:04:34.691775991 +0100
7a8017
+++ which-2.21/which.c	2021-03-21 21:04:34.692775983 +0100
7a8017
@@ -76,8 +76,9 @@ static int skip_functions = 0, read_func
7a8017
 
7a8017
 static char *find_command_in_path(const char *name, const char *path_list, int *path_index)
7a8017
 {
7a8017
-  char *found = NULL, *full_path;
7a8017
+  char *found = NULL, *full_path = NULL;
7a8017
   int status, name_len;
7a8017
+  char *p;
7a8017
 
7a8017
   name_len = strlen(name);
7a8017
 
7a8017
@@ -85,7 +86,6 @@ static char *find_command_in_path(const
7a8017
     absolute_path_given = 0;
7a8017
   else
7a8017
   {
7a8017
-    char *p;
7a8017
     absolute_path_given = 1;
7a8017
 
7a8017
     if (abs_path)
7a8017
@@ -159,6 +159,7 @@ static char *find_command_in_path(const
7a8017
     free(full_path);
7a8017
   }
7a8017
 
7a8017
+  name = NULL; p = NULL; path_list = NULL;
7a8017
   return (found);
7a8017
 }
7a8017
 
7a8017
@@ -540,7 +541,7 @@ int main(int argc, char *argv[])
7a8017
   int function_start_type = 0;
7a8017
   if (read_alias || read_functions)
7a8017
   {
7a8017
-    char buf[1024];
7a8017
+    char buf[1024] = {};
7a8017
     int processing_aliases = read_alias;
7a8017
 
7a8017
     if (isatty(0))