On Fri, May 10, 2024 at 01:25:07PM +0200, Patrick Steinhardt wrote: > @@ -638,34 +657,40 @@ static char *default_user_config(void) [snip] > - if (use_global_config) { > - given_config_source.file = git_global_config(); > - if (!given_config_source.file) > + if (opts->use_global_config) { > + opts->source.file = xstrdup_or_null(git_global_config()); > + if (!opts->source.file) This needs the following on top to plug a memory leak -- I didn't realize that `git_global_config()` transfers ownership of the string to the caller already. diff --git a/builtin/config.c b/builtin/config.c index 127bc097b2..30a49d07d7 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -761,7 +761,7 @@ static void location_options_init(struct config_location_options *opts, } if (opts->use_global_config) { - opts->source.file = xstrdup_or_null(git_global_config()); + opts->source.file = git_global_config(); if (!opts->source.file) /* * It is unknown if HOME/.gitconfig exists, so Will fix in v2. Patrick
Attachment:
signature.asc
Description: PGP signature