submodule--helper: plug mem leak in print_default_remote
authorStefan Beller <sbeller@google.com>
Wed, 30 May 2018 17:03:02 +0000 (10:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jun 2018 05:52:47 +0000 (14:52 +0900)
Signed-off-by: Stefan Beller <sbeller@google.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
[jc: no need for remote to be const char *]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
index bd250ca2164b31356fb42406351761cd2381d115..7a752dbf9db65dfccb828cc3890340212a63bc82 100644 (file)
@@ -55,7 +55,7 @@ static char *get_default_remote(void)
 
 static int print_default_remote(int argc, const char **argv, const char *prefix)
 {
-       const char *remote;
+       char *remote;
 
        if (argc != 1)
                die(_("submodule--helper print-default-remote takes no arguments"));
@@ -64,6 +64,7 @@ static int print_default_remote(int argc, const char **argv, const char *prefix)
        if (remote)
                printf("%s\n", remote);
 
+       free(remote);
        return 0;
 }