]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: avoid memory leak when fetching submodules
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 15 Jun 2022 23:35:41 +0000 (23:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jun 2022 20:22:03 +0000 (13:22 -0700)
In c51f8f94e5b3 (submodule--helper: run update procedures from C,
2021-08-24), we added code that first obtains the default remote, and
then adds that to a `strvec`.

However, we never released the default remote's memory.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c

index 5c77dfcffee65d753f3a650c4d700eec35348236..c597df7528ee56cd1e35c65f409e73a99769a5ee 100644 (file)
@@ -2208,6 +2208,7 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str
                char *hex = oid_to_hex(oid);
                char *remote = get_default_remote();
                strvec_pushl(&cp.args, remote, hex, NULL);
+               free(remote);
        }
 
        return run_command(&cp);