From: Eric Sunshine Date: Mon, 02 May 2016 17:42:55 GMT Subject: Re: [PATCH 73/83] builtin/apply: make write_out_results() return -1 on error Message-ID: In-Reply-To: <1461504863-15946-74-git-send-email-chriscool@tuxfamily.org> On Sun, Apr 24, 2016 at 9:34 AM, Christian Couder wrote: > Signed-off-by: Christian Couder > --- > diff --git a/builtin/apply.c b/builtin/apply.c > @@ -4381,7 +4387,7 @@ static int write_out_results(struct apply_state *state, struct patch *list) > errs = 1; > else { > if (write_out_one_result(state, l, phase)) > - exit(1); > + return -1; Isn't this leaking 'string_list cpath'? > if (phase == 1) { > if (write_out_one_reject(state, l)) > errs = 1; > @@ -4484,11 +4490,16 @@ static int apply_patch(struct apply_state *state, > !state->apply_with_reject) > return -1; > > - if (state->apply && write_out_results(state, list)) { > - if (state->apply_with_reject) > + if (state->apply) { > + int res = write_out_results(state, list); > + if (res < 0) > return -1; Mentioned previously: Leaking 'list', 'buf', 'fn_table'. > - /* with --3way, we still need to write the index out */ > - return 1; > + if (res > 0) { > + if (state->apply_with_reject) > + return -1; > + /* with --3way, we still need to write the index out */ > + return 1; Not the fault of this patch, but this 'return' in the original code was also leaking 'list', 'buf', 'fn_table', right? > + } > } > > if (state->fake_ancestor &&