{"thread":{"id":"45760","subject":"[PATCH] connect.c: fix leak in handle_ssh_variant","startedAt":"2017-04-20T20:22:10Z","lastAt":"2017-04-20T20:22:10Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"317372","messageId":"20170420202157.l2un35omz4vhffny@sigill.intra.peff.net","threadId":"45760","inReplyTo":null,"subject":"[PATCH] connect.c: fix leak in handle_ssh_variant","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-04-20T20:21:58Z","receivedAt":"2017-04-20T20:22:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"When we see an error from split_cmdline(), we exit the\nfunction without freeing the copy of the command string we\nmade.\n\nThis was sort-of introduced by 22e5ae5c8 (connect.c: handle\nerrors from split_cmdline, 2017-04-10). The leak existed\nbefore that, but before that commit fixed the bug, we could\nnever trigger this else clause in the first place.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis was meant to be part of the original patch in:\n\n  http://public-inbox.org/git/20170411003554.2tjnn65vfco376kj@sigill.intra.peff.net/\n\nbut I posted two versions in quick succession and Junio picked up the\nfirst one. :)\n\n connect.c | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/connect.c b/connect.c\nindex 568a35f75..cd21a1b6f 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -738,8 +738,10 @@ static void handle_ssh_variant(const char *ssh_command, int is_cmdline,\n \t\t\t * any longer.\n \t\t\t */\n \t\t\tfree(ssh_argv);\n-\t\t} else\n+\t\t} else {\n+\t\t\tfree(p);\n \t\t\treturn;\n+\t\t}\n \t}\n \n \tif (!strcasecmp(variant, \"plink\") ||\n-- \n2.13.0.rc0.363.g8726c260e\n"}]}