From b301a6746f7b2181266c1a5dc2d8bf38d31b263d Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 6 Aug 2021 13:29:27 +0200 Subject: [PATCH] Initialize struct stat s ourself because clang sanitizer thinks it's unknown if the structure is initialized in full by stat() call --- src/shared.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/shared.c b/src/shared.c index 9bff0c646..919948232 100644 --- a/src/shared.c +++ b/src/shared.c @@ -313,6 +313,8 @@ bool hc_path_is_file (const char *path) { struct stat s; + memset (&s, 0, sizeof (s)); + if (stat (path, &s) == -1) return false; if (S_ISREG (s.st_mode)) return true; @@ -324,6 +326,8 @@ bool hc_path_is_directory (const char *path) { struct stat s; + memset (&s, 0, sizeof (s)); + if (stat (path, &s) == -1) return false; if (S_ISDIR (s.st_mode)) return true; @@ -335,6 +339,8 @@ bool hc_path_is_empty (const char *path) { struct stat s; + memset (&s, 0, sizeof (s)); + if (stat (path, &s) == -1) return false; if (s.st_size == 0) return true; @@ -678,6 +684,9 @@ bool hc_same_files (char *file1, char *file2) struct stat tmpstat_file1; struct stat tmpstat_file2; + memset (&tmpstat_file1, 0, sizeof (tmpstat_file1)); + memset (&tmpstat_file2, 0, sizeof (tmpstat_file2)); + int do_check = 0; HCFILE fp;