From 4530a85b4c34f009b5f190eb2dc8367801de5028 Mon Sep 17 00:00:00 2001 From: Alexandr Miloslavskiy Date: Tue, 10 Mar 2020 13:11:23 +0000 Subject: real_path_if_valid(): remove unsafe API This commit continues the work started with previous commit. Signed-off-by: Alexandr Miloslavskiy Signed-off-by: Junio C Hamano --- worktree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'worktree.c') diff --git a/worktree.c b/worktree.c index e7bbf716f6..543472f0c7 100644 --- a/worktree.c +++ b/worktree.c @@ -226,17 +226,20 @@ struct worktree *find_worktree(struct worktree **list, struct worktree *find_worktree_by_path(struct worktree **list, const char *p) { + struct strbuf wt_path = STRBUF_INIT; char *path = real_pathdup(p, 0); if (!path) return NULL; for (; *list; list++) { - const char *wt_path = real_path_if_valid((*list)->path); + if (!strbuf_realpath(&wt_path, (*list)->path, 0)) + continue; - if (wt_path && !fspathcmp(path, wt_path)) + if (!fspathcmp(path, wt_path.buf)) break; } free(path); + strbuf_release(&wt_path); return *list; } -- cgit v1.2.3