]> Kevux Git Server - rit/commitdiff
urlmatch.c: add and use a *_release() function
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 4 Mar 2022 18:32:07 +0000 (19:32 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Mar 2022 21:24:18 +0000 (13:24 -0800)
Plug a memory leak in credential_apply_config() by adding and using a
new urlmatch_config_release() function. This just does a
string_list_clear() on the "vars" member.

This finished up work on normalizing the init/free pattern in this
API, started in 73ee449bbf2 (urlmatch.[ch]: add and use
URLMATCH_CONFIG_INIT, 2021-10-01).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c
credential.c
urlmatch.c
urlmatch.h

index 542d8d0..ebec618 100644 (file)
@@ -612,7 +612,7 @@ static int get_urlmatch(const char *var, const char *url)
 
                strbuf_release(&matched->value);
        }
-       string_list_clear(&config.vars, 1);
+       urlmatch_config_release(&config);
        string_list_clear(&values, 1);
        free(config.url.url);
 
index e7240f3..f6389a5 100644 (file)
@@ -130,6 +130,7 @@ static void credential_apply_config(struct credential *c)
        git_config(urlmatch_config_entry, &config);
        string_list_clear(&config.vars, 1);
        free(normalized_url);
+       urlmatch_config_release(&config);
        strbuf_release(&url);
 
        c->configured = 1;
index 03ad3f3..b615adc 100644 (file)
@@ -611,3 +611,8 @@ int urlmatch_config_entry(const char *var, const char *value, void *cb)
        strbuf_release(&synthkey);
        return retval;
 }
+
+void urlmatch_config_release(struct urlmatch_config *config)
+{
+       string_list_clear(&config->vars, 1);
+}
index 34a3ba6..9f40b00 100644 (file)
@@ -71,5 +71,6 @@ struct urlmatch_config {
 }
 
 int urlmatch_config_entry(const char *var, const char *value, void *cb);
+void urlmatch_config_release(struct urlmatch_config *config);
 
 #endif /* URL_MATCH_H */