{"thread":{"id":"27585","subject":"[PATCH] fetch: do not leak a refspec","startedAt":"2011-06-08T20:06:33Z","lastAt":"2011-06-09T00:20:46Z","messageCount":2,"participants":["Jim Meyering","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"169692","messageId":"87vcwgxf3q.fsf@rho.meyering.net","threadId":"27585","inReplyTo":null,"subject":"[PATCH] fetch: do not leak a refspec","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2011-06-08T20:06:33Z","receivedAt":"2011-06-08T20:06:33Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"\n\nSigned-off-by: Jim Meyering <meyering@redhat.com>\n---\nCoverity spotted this.\n\n builtin/fetch.c |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex f9c41da..93c9938 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -875,6 +875,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)\n {\n \tint i;\n \tstatic const char **refs = NULL;\n+\tstruct refspec *refspec;\n \tint ref_nr = 0;\n \tint exit_code;\n\n@@ -915,8 +916,9 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)\n\n \tsigchain_push_common(unlock_pack_on_signal);\n \tatexit(unlock_pack);\n-\texit_code = do_fetch(transport,\n-\t\t\tparse_fetch_refspec(ref_nr, refs), ref_nr);\n+\trefspec = parse_fetch_refspec(ref_nr, refs);\n+\texit_code = do_fetch(transport, refspec, ref_nr);\n+\tfree(refspec);\n \ttransport_disconnect(transport);\n \ttransport = NULL;\n \treturn exit_code;\n--\n1.7.6.rc0.293.g40857\n"},{"id":"169715","messageId":"7vaadr26u9.fsf@alter.siamese.dyndns.org","threadId":"27585","inReplyTo":"87vcwgxf3q.fsf@rho.meyering.net","subject":"Re: [PATCH] fetch: do not leak a refspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-06-09T00:20:46Z","receivedAt":"2011-06-09T00:20:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jim Meyering <jim@meyering.net> writes:\n\n> Signed-off-by: Jim Meyering <meyering@redhat.com>\n> ---\n> Coverity spotted this.\n\nThanks, will apply, but it seems that Coverity does not know or care that\nthis codepath is used only once in the process and the process immediately\nexits after the small leak that we didn't bother spending two extra lines\nto plug, which is kind of sad.\n\n>  builtin/fetch.c |    6 ++++--\n>  1 files changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/fetch.c b/builtin/fetch.c\n> index f9c41da..93c9938 100644\n> --- a/builtin/fetch.c\n> +++ b/builtin/fetch.c\n> @@ -875,6 +875,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)\n>  {\n>  \tint i;\n>  \tstatic const char **refs = NULL;\n> +\tstruct refspec *refspec;\n>  \tint ref_nr = 0;\n>  \tint exit_code;\n>\n> @@ -915,8 +916,9 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)\n>\n>  \tsigchain_push_common(unlock_pack_on_signal);\n>  \tatexit(unlock_pack);\n> -\texit_code = do_fetch(transport,\n> -\t\t\tparse_fetch_refspec(ref_nr, refs), ref_nr);\n> +\trefspec = parse_fetch_refspec(ref_nr, refs);\n> +\texit_code = do_fetch(transport, refspec, ref_nr);\n> +\tfree(refspec);\n>  \ttransport_disconnect(transport);\n>  \ttransport = NULL;\n>  \treturn exit_code;\n> --\n> 1.7.6.rc0.293.g40857\n"}]}