Commit 43ff8261e1c6fdb609986add011ed0313f6eabe6

Stefan Sperling 2019-12-13T10:01:49

check for fclose() failure in get_file_status()

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/lib/worktree.c b/lib/worktree.c
index b5e37a2..9eb8aa6 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1210,7 +1210,7 @@ get_file_status(unsigned char *status, struct stat *sb,
 done:
 	if (blob)
 		got_object_blob_close(blob);
-	if (f)
+	if (f != NULL && fclose(f) == EOF && err == NULL)
 		fclose(f);
 	if (fd != -1 && close(fd) == -1 && err == NULL)
 		err = got_error_from_errno2("close", abspath);