Blame SOURCES/which-2.21-coverity-fixes.patch

79d63a
diff -up which-2.21/tilde/tilde.c.coverity which-2.21/tilde/tilde.c
79d63a
--- which-2.21/tilde/tilde.c.coverity	2008-01-16 18:51:57.000000000 +0100
79d63a
+++ which-2.21/tilde/tilde.c	2021-03-21 11:43:00.338160051 +0100
79d63a
@@ -193,10 +193,10 @@ tilde_expand (string)
79d63a
      const char *string;
79d63a
 {
79d63a
   char *result;
79d63a
-  int result_size, result_index;
79d63a
+  int result_size = 0, result_index = 0;
79d63a
 
79d63a
-  result_index = result_size = 0;
79d63a
-  if (result = strchr (string, '~'))
79d63a
+  result = strchr (string, '~');
79d63a
+  if (result)
79d63a
     result = (char *)xmalloc (result_size = (strlen (string) + 16));
79d63a
   else
79d63a
     result = (char *)xmalloc (result_size = (strlen (string) + 1));
79d63a
@@ -270,7 +270,7 @@ isolate_tilde_prefix (fname, lenp)
79d63a
   char *ret;
79d63a
   int i;
79d63a
 
79d63a
-  ret = (char *)xmalloc (strlen (fname));
79d63a
+  ret = (char *)xmalloc (strlen (fname) + 1);
79d63a
 #if defined (__MSDOS__)
79d63a
   for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
79d63a
 #else
79d63a
diff -up which-2.21/which.c.coverity which-2.21/which.c
79d63a
--- which-2.21/which.c.coverity	2015-03-19 17:50:24.000000000 +0100
79d63a
+++ which-2.21/which.c	2021-03-21 12:19:31.289160885 +0100
79d63a
@@ -76,16 +76,16 @@ static int skip_functions = 0, read_func
79d63a
 
79d63a
 static char *find_command_in_path(const char *name, const char *path_list, int *path_index)
79d63a
 {
79d63a
-  char *found = NULL, *full_path;
79d63a
+  char *found = NULL, *full_path = NULL;
79d63a
   int status, name_len;
79d63a
 
79d63a
   name_len = strlen(name);
79d63a
+  char *p;
79d63a
 
79d63a
   if (!absolute_program(name))
79d63a
     absolute_path_given = 0;
79d63a
   else
79d63a
   {
79d63a
-    char *p;
79d63a
     absolute_path_given = 1;
79d63a
 
79d63a
     if (abs_path)
79d63a
@@ -159,6 +159,7 @@ static char *find_command_in_path(const
79d63a
     free(full_path);
79d63a
   }
79d63a
 
79d63a
+  name = NULL; p = NULL; path_list = NULL;
79d63a
   return (found);
79d63a
 }
79d63a
 
79d63a
@@ -540,7 +541,7 @@ int main(int argc, char *argv[])
79d63a
   int function_start_type = 0;
79d63a
   if (read_alias || read_functions)
79d63a
   {
79d63a
-    char buf[1024];
79d63a
+    char buf[1024] = {};
79d63a
     int processing_aliases = read_alias;
79d63a
 
79d63a
     if (isatty(0))