From: Junio C Hamano Date: Thu, 09 Jul 2026 03:53:07 GMT Subject: Re: [PATCH v8 4/9] environment: move pager_program into repo_config_values Message-ID: In-Reply-To: <20260708160300.8852-5-cat@malon.dev> Tian Yuchen writes: > On top of that, fix a memory leak in pager.c while we are at it. Hmph. > @@ -75,10 +76,12 @@ static void wait_for_pager_signal(int signo) > > static int core_pager_config(const char *var, const char *value, > const struct config_context *ctx UNUSED, > - void *data UNUSED) > + void *data) > { > + struct repository *r = data; > + > if (!strcmp(var, "core.pager")) > - return git_config_string(&pager_program, var, value); > + return git_config_string(&repo_config_values(r)->pager_program, var, value); Isn't this still overwriting what was in the .pager_program member of the config values struct? In check_pager_config() below, there is a free() to avoid such a leak, but wouldn't this have the same issue? > @@ -91,10 +94,10 @@ const char *git_pager(struct repository *r, int stdout_is_tty) > > pager = getenv("GIT_PAGER"); > if (!pager) { > - if (!pager_program) > + if (!repo_config_values(r)->pager_program) > read_early_config(r, > - core_pager_config, NULL); > - pager = pager_program; > + core_pager_config, r); > + pager = repo_config_values(r)->pager_program; > } > if (!pager) > pager = getenv("PAGER"); > @@ -302,7 +305,9 @@ int check_pager_config(struct repository *r, const char *cmd) > > read_early_config(r, pager_command_config, &data); > > - if (data.value) > - pager_program = data.value; > + if (data.value) { > + free(repo_config_values(r)->pager_program); > + repo_config_values(r)->pager_program = data.value; > + } > return data.want; > }