setup: free old value before setting `work_tree`
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 1be5037f129646cd46d3dc048e8f58dc3bdac0b9..bb633942bba11f8f0289ec992a6a14a3d01c975a 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -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;