Commit b15bc87b1884e0d5a69df4536d29a8a8af8a745b

Stefan Sperling 2020-07-23T14:21:29

fix memory leak in install_symlink() error path; spotted by semarie

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 7ac3e89..be2544b 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1006,8 +1006,10 @@ install_symlink(struct got_worktree *worktree, const char *ondisk_path,
 	 */
 	resolved_path = realpath(abspath ? abspath : target_path, NULL);
 	if (resolved_path == NULL) {
-		if (errno != ENOENT)
-			return got_error_from_errno2("realpath", target_path);
+		if (errno != ENOENT) {
+			err = got_error_from_errno2("realpath", target_path);
+			goto done;
+		}
 	}
 
 	/* Only allow symlinks pointing at paths within the work tree. */