diff options
Diffstat (limited to 'worktree.c')
-rw-r--r-- | worktree.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/worktree.c b/worktree.c index 42dd3d52b0..bae787cf8d 100644 --- a/worktree.c +++ b/worktree.c @@ -250,16 +250,19 @@ struct worktree *find_worktree(struct worktree **list, { struct worktree *wt; char *path; + char *to_free = NULL; if ((wt = find_worktree_by_suffix(list, arg))) return wt; - arg = prefix_filename(prefix, arg); + if (prefix) + arg = to_free = prefix_filename(prefix, arg); path = real_pathdup(arg, 1); for (; *list; list++) if (!fspathcmp(path, real_path((*list)->path))) break; free(path); + free(to_free); return *list; } |