From f13992917b97766a29ecd05caea7f74431fb30a6 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Wed, 30 Aug 2017 19:49:39 +0200 Subject: connect: release strbuf on error return in git_connect() Reduce the scope of the variable cmd and release it before returning early. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- connect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'connect.c') diff --git a/connect.c b/connect.c index 49b28b83b..df56c0cbf 100644 --- a/connect.c +++ b/connect.c @@ -778,7 +778,6 @@ struct child_process *git_connect(int fd[2], const char *url, char *hostandport, *path; struct child_process *conn = &no_fork; enum protocol protocol; - struct strbuf cmd = STRBUF_INIT; /* Without this we cannot rely on waitpid() to tell * what happened to our children. @@ -826,6 +825,8 @@ struct child_process *git_connect(int fd[2], const char *url, target_host, 0); free(target_host); } else { + struct strbuf cmd = STRBUF_INIT; + conn = xmalloc(sizeof(*conn)); child_process_init(conn); @@ -862,6 +863,7 @@ struct child_process *git_connect(int fd[2], const char *url, free(hostandport); free(path); free(conn); + strbuf_release(&cmd); return NULL; } -- cgit v1.2.1