Jeff King <[email protected]> writes:
> diff --git a/worktree.c b/worktree.c
> index 42dd3d52b..2520fc65c 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;
>
> 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;
> }
worktree.c:265:6: error: to_free may be used uninitialized in this function
---
worktree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/worktree.c b/worktree.c
index 2520fc65cc..bae787cf8d 100644
--- a/worktree.c
+++ b/worktree.c
@@ -250,7 +250,7 @@ struct worktree *find_worktree(struct worktree **list,
{
struct worktree *wt;
char *path;
- char *to_free;
+ char *to_free = NULL;
if ((wt = find_worktree_by_suffix(list, arg)))
return wt;
--
2.12.1-382-gc0f9c70589