Commit f4994adcb43b7e46b012a47d9a749f7c2625796e

Stefan Sperling 2020-10-20T21:09:01

use got_path_dirname() in install_symlink() to avoid const dirname(3) ok naddy

diff --git a/lib/worktree.c b/lib/worktree.c
index cd71af8..397a788 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1414,13 +1414,12 @@ install_symlink(int *is_bad_symlink, struct got_worktree *worktree,
 		}
 
 		if (errno == ENOENT) {
-			char *parent = dirname(ondisk_path);
-			if (parent == NULL) {
-				err = got_error_from_errno2("dirname",
-				    ondisk_path);
+			char *parent;
+			err = got_path_dirname(&parent, ondisk_path);
+			if (err)
 				goto done;
-			}
 			err = add_dir_on_disk(worktree, parent);
+			free(parent);
 			if (err)
 				goto done;
 			/*