Skip to content

Commit f139929

Browse files
rscharfegitster
authored andcommitted
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>
1 parent e505146 commit f139929

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

connect.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ struct child_process *git_connect(int fd[2], const char *url,
778778
char *hostandport, *path;
779779
struct child_process *conn = &no_fork;
780780
enum protocol protocol;
781-
struct strbuf cmd = STRBUF_INIT;
782781

783782
/* Without this we cannot rely on waitpid() to tell
784783
* what happened to our children.
@@ -826,6 +825,8 @@ struct child_process *git_connect(int fd[2], const char *url,
826825
target_host, 0);
827826
free(target_host);
828827
} else {
828+
struct strbuf cmd = STRBUF_INIT;
829+
829830
conn = xmalloc(sizeof(*conn));
830831
child_process_init(conn);
831832

@@ -862,6 +863,7 @@ struct child_process *git_connect(int fd[2], const char *url,
862863
free(hostandport);
863864
free(path);
864865
free(conn);
866+
strbuf_release(&cmd);
865867
return NULL;
866868
}
867869

0 commit comments

Comments
 (0)