mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
config: clarify memory ownership in git_config_pathname()
The out parameter of `git_config_pathname()` is a `const char **` even though we transfer ownership of memory to the caller. This is quite misleading and has led to many memory leaks all over the place. Adapt the parameter to instead be `char **`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
f962ffc392
commit
6073b3b5c3
@@ -103,6 +103,7 @@ static struct fsmonitor_settings *alloc_settings(void)
|
||||
static void lookup_fsmonitor_settings(struct repository *r)
|
||||
{
|
||||
const char *const_str;
|
||||
char *to_free = NULL;
|
||||
int bool_value;
|
||||
|
||||
if (r->settings.fsmonitor)
|
||||
@@ -129,8 +130,9 @@ static void lookup_fsmonitor_settings(struct repository *r)
|
||||
break;
|
||||
|
||||
case -1: /* config value set to an arbitrary string */
|
||||
if (repo_config_get_pathname(r, "core.fsmonitor", &const_str))
|
||||
if (repo_config_get_pathname(r, "core.fsmonitor", &to_free))
|
||||
return; /* should not happen */
|
||||
const_str = to_free;
|
||||
break;
|
||||
|
||||
default: /* should not happen */
|
||||
@@ -141,6 +143,7 @@ static void lookup_fsmonitor_settings(struct repository *r)
|
||||
fsm_settings__set_hook(r, const_str);
|
||||
else
|
||||
fsm_settings__set_disabled(r);
|
||||
free(to_free);
|
||||
}
|
||||
|
||||
enum fsmonitor_mode fsm_settings__get_mode(struct repository *r)
|
||||
|
||||
Reference in New Issue
Block a user