OSDN Git Service

connect.c: fix leak in handle_ssh_variant
authorJeff King <peff@peff.net>
Thu, 20 Apr 2017 20:21:58 +0000 (16:21 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Apr 2017 05:02:14 +0000 (22:02 -0700)
When we see an error from split_cmdline(), we exit the
function without freeing the copy of the command string we
made.

This was sort-of introduced by 22e5ae5c8 (connect.c: handle
errors from split_cmdline, 2017-04-10). The leak existed
before that, but before that commit fixed the bug, we could
never trigger this else clause in the first place.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
connect.c

index 6f2281a..380997a 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -738,8 +738,10 @@ static void handle_ssh_variant(const char *ssh_command, int is_cmdline,
                         * any longer.
                         */
                        free(ssh_argv);
-               } else
+               } else {
+                       free(p);
                        return;
+               }
        }
 
        if (!strcasecmp(variant, "plink") ||