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 --- http.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index db2e2f1d39..fa3ea87451 100644 --- a/http.c +++ b/http.c @@ -64,7 +64,7 @@ static char *ssl_key_type; static char *ssl_capath; static char *curl_no_proxy; #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY -static const char *ssl_pinnedkey; +static char *ssl_pinnedkey; #endif static char *ssl_cainfo; static long curl_low_speed_limit = -1; @@ -108,7 +108,7 @@ static struct { static struct credential proxy_auth = CREDENTIAL_INIT; static const char *curl_proxyuserpwd; -static const char *curl_cookie_file; +static char *curl_cookie_file; static int curl_save_cookies; struct credential http_auth = CREDENTIAL_INIT; static int http_proactive_auth; @@ -381,17 +381,17 @@ static int http_options(const char *var, const char *value, if (!strcmp("http.sslversion", var)) return git_config_string(&ssl_version, var, value); if (!strcmp("http.sslcert", var)) - return git_config_pathname((const char **)&ssl_cert, var, value); + return git_config_pathname(&ssl_cert, var, value); if (!strcmp("http.sslcerttype", var)) return git_config_string((const char **)&ssl_cert_type, var, value); if (!strcmp("http.sslkey", var)) - return git_config_pathname((const char **)&ssl_key, var, value); + return git_config_pathname(&ssl_key, var, value); if (!strcmp("http.sslkeytype", var)) return git_config_string((const char **)&ssl_key_type, var, value); if (!strcmp("http.sslcapath", var)) - return git_config_pathname((const char **)&ssl_capath, var, value); + return git_config_pathname(&ssl_capath, var, value); if (!strcmp("http.sslcainfo", var)) - return git_config_pathname((const char **)&ssl_cainfo, var, value); + return git_config_pathname(&ssl_cainfo, var, value); if (!strcmp("http.sslcertpasswordprotected", var)) { ssl_cert_password_required = git_config_bool(var, value); return 0; -- cgit v1.3-6-g1900