From c8d1351deb2ccb8634d5c3dd863dd37d0d8c082c Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 28 May 2013 22:56:21 -0500 Subject: sequencer: remove useless indentation By using good ol' goto. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- sequencer.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sequencer.c b/sequencer.c index ab6f8a722d..b4989ba2c3 100644 --- a/sequencer.c +++ b/sequencer.c @@ -474,7 +474,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts) struct commit_message msg = { NULL, NULL, NULL, NULL, NULL }; char *defmsg = NULL; struct strbuf msgbuf = STRBUF_INIT; - int res, unborn = 0; + int res, unborn = 0, allow; if (opts->no_commit) { /* @@ -624,14 +624,16 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts) msg.subject); print_advice(res == 1, opts); rerere(opts->allow_rerere_auto); - } else { - int allow = allow_empty(opts, commit); - if (allow < 0) - return allow; - if (!opts->no_commit) - res = run_git_commit(defmsg, opts, allow); + goto leave; } + allow = allow_empty(opts, commit); + if (allow < 0) + return allow; + if (!opts->no_commit) + res = run_git_commit(defmsg, opts, allow); + +leave: free_message(&msg); free(defmsg); -- cgit v1.2.3 From 706728a37c53c3d1c3fc38aa9c9842060d03e9cc Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 6 Jun 2013 03:58:57 -0500 Subject: sequencer: avoid leaking message buffer when refusing to create an empty commit We should free objects before leaving. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- sequencer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sequencer.c b/sequencer.c index b4989ba2c3..f7be7d8be6 100644 --- a/sequencer.c +++ b/sequencer.c @@ -628,8 +628,10 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts) } allow = allow_empty(opts, commit); - if (allow < 0) - return allow; + if (allow < 0) { + res = allow; + goto leave; + } if (!opts->no_commit) res = run_git_commit(defmsg, opts, allow); -- cgit v1.2.3