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>
Rene Scharfe committed
Aug 30, 2017 at 19:49 UTC
f13992917b97766a29ecd05caea7f74431fb30a6
1 file changed
+3
-1
connect.c
+3
-1
@@ -778,7 +778,6 @@ struct child_process *git_connect(int fd[2], const char *url,
778
char *hostandport, *path;
779
struct child_process *conn = &no_fork;
780
enum protocol protocol;
781
- struct strbuf cmd = STRBUF_INIT;
781
782
/* Without this we cannot rely on waitpid() to tell
783
* what happened to our children.
@@ -826,6 +825,8 @@ struct child_process *git_connect(int fd[2], const char *url,
825
target_host, 0);
826
free(target_host);
827
} else {
828
+ struct strbuf cmd = STRBUF_INIT;
829
+
830
conn = xmalloc(sizeof(*conn));
831
child_process_init(conn);
832
@@ -862,6 +863,7 @@ struct child_process *git_connect(int fd[2], const char *url,
863
free(hostandport);
864
free(path);
865
free(conn);
866
+ strbuf_release(&cmd);
867
return NULL;
868
}
869