Skip to content

Commit

Permalink
setup: free old value before setting work_tree
Browse files Browse the repository at this point in the history
Before assigning to `data->work_tree` in `read_worktree_config()`, free
any value we might already have picked up, so that we do not leak it.

Signed-off-by: Martin Ågren <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Martin Ågren authored and gitster committed Jan 23, 2019
1 parent ecbdaf0 commit 1301997
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ static int read_worktree_config(const char *var, const char *value, void *vdata)
} else if (strcmp(var, "core.worktree") == 0) {
if (!value)
return config_error_nonbool(var);
free(data->work_tree);
data->work_tree = xstrdup(value);
}
return 0;
Expand Down

0 comments on commit 1301997

Please sign in to comment.