Re: [PATCH 06/26] get_mail_commit_oid(): avoid resource leak
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Apr 28, 2017, 10:02 UTC
- Message-ID
- <alpine.DEB.2.20.1704281201570.3480@virtualbox>
- In-Reply-To
- <ac257961-3133-0de4-d918-cfb8da8fbf89@kdbg.org>
Hi Hannes,
On Thu, 27 Apr 2017, Johannes Sixt wrote:
Show 32 quoted lines
> Am 26.04.2017 um 22:19 schrieb Johannes Schindelin: > > > > diff --git a/builtin/am.c b/builtin/am.c > > index 805f56cec2f..01b700e5e74 100644 > > --- a/builtin/am.c > > +++ b/builtin/am.c > > @@ -1359,15 +1359,16 @@ static int get_mail_commit_oid(struct object_id > > *commit_id, const char *mail) > > struct strbuf sb = STRBUF_INIT; > > FILE *fp = xfopen(mail, "r"); > > const char *x; > > + int ret = 0; > > > > if (strbuf_getline_lf(&sb, fp)) > > - return -1; > > + ret = -1; > > > > - if (!skip_prefix(sb.buf, "From ", &x)) > > - return -1; > > + if (!ret && !skip_prefix(sb.buf, "From ", &x)) > > + ret = -1; > > > > - if (get_oid_hex(x, commit_id) < 0) > > - return -1; > > + if (!ret && get_oid_hex(x, commit_id) < 0) > > + ret = -1; > > > > strbuf_release(&sb); > > fclose(fp); > > > > You forgot to 'return ret;', didn't you?
I sure did!
Thanks, Dscho