diff options
author | Rene Scharfe <l.s.r@web.de> | 2017-08-30 19:49:39 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-07 08:49:27 +0900 |
commit | f13992917b97766a29ecd05caea7f74431fb30a6 (patch) | |
tree | 74113a880b9c8435a9f8685369d567a45e5751ff | |
parent | e505146dac276cc051eca199f9dc7ca88bef5f18 (diff) | |
download | git-f13992917b97766a29ecd05caea7f74431fb30a6.tar.gz git-f13992917b97766a29ecd05caea7f74431fb30a6.tar.xz |
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 <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | connect.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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; } |