Blame SOURCES/which-2.21-coverity.patch

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