From 6073b3b5c37716c50244d635e7c358f41f43e286 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 27 May 2024 13:46:15 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setup.c') diff --git a/setup.c b/setup.c index 9247cded6a..59ff3a19eb 100644 --- a/setup.c +++ b/setup.c @@ -1177,13 +1177,13 @@ static int safe_directory_cb(const char *key, const char *value, } else if (!strcmp(value, "*")) { data->is_safe = 1; } else { - const char *interpolated = NULL; + char *interpolated = NULL; if (!git_config_pathname(&interpolated, key, value) && !fspathcmp(data->path, interpolated ? interpolated : value)) data->is_safe = 1; - free((char *)interpolated); + free(interpolated); } return 0; @@ -1822,7 +1822,7 @@ static int template_dir_cb(const char *key, const char *value, char *path = NULL; FREE_AND_NULL(data->path); - if (!git_config_pathname((const char **)&path, key, value)) + if (!git_config_pathname(&path, key, value)) data->path = path ? path : xstrdup(value); } -- cgit v1.2.3