Converting pull.twohead and pull.octopus to use git_config_string_dup() fixes possible leaks if we see those config variables defined multiple times. Doing so is mostly an "easy" case, except that we later may assign a string literal to pull_twohead (which is now a non-const pointer). That's actually not _too_ bad in practice, as it happens after we've done all of our config parsing (so nobody would try to free it). And the compiler won't complain unless -Wwrite-strings is used (and turning that on creates a host of other warnings, some useful and some not). But while we're here let's future proof it as best we can. Signed-off-by: Jeff King <peff@xxxxxxxx> --- builtin/merge.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index c2be29ed2f..a9e5100e70 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -101,7 +101,7 @@ static struct strategy all_strategy[] = { { "subtree", NO_FAST_FORWARD | NO_TRIVIAL }, }; -static const char *pull_twohead, *pull_octopus; +static char *pull_twohead, *pull_octopus; enum ff_type { FF_NO, @@ -615,9 +615,9 @@ static int git_merge_config(const char *k, const char *v, else if (!strcmp(k, "merge.verifysignatures")) verify_signatures = git_config_bool(k, v); else if (!strcmp(k, "pull.twohead")) - return git_config_string(&pull_twohead, k, v); + return git_config_string_dup(&pull_twohead, k, v); else if (!strcmp(k, "pull.octopus")) - return git_config_string(&pull_octopus, k, v); + return git_config_string_dup(&pull_octopus, k, v); else if (!strcmp(k, "commit.cleanup")) return git_config_string_dup(&cleanup_arg, k, v); else if (!strcmp(k, "merge.ff")) { @@ -1291,7 +1291,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (!pull_twohead) { char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM"); if (default_strategy && !strcmp(default_strategy, "ort")) - pull_twohead = "ort"; + pull_twohead = xstrdup("ort"); } init_diff_ui_defaults(); -- 2.44.0.872.g288abe5b5b