Commit ab0d43616704b463cc02e5c8ea982dcf10f83f4b

Stefan Sperling 2019-12-13T12:00:10

fix leak in an error path of get_file_status()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/worktree.c b/lib/worktree.c
index 626e3c5..2e614c8 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1184,8 +1184,10 @@ get_file_status(unsigned char *status, struct stat *sb,
 
 	if (dirfd != -1) {
 		fd = openat(dirfd, de_name, O_RDONLY | O_NOFOLLOW);
-		if (fd == -1)
-			return got_error_from_errno2("openat", abspath);
+		if (fd == -1) {
+			err = got_error_from_errno2("openat", abspath);
+			goto done;
+		}
 	}
 
 	f = fdopen(fd, "r");