From: Jeff King <peff@peff.net>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: Stefan Beller <stefanbeller@googlemail.com>,
git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] mailmap: fix check for freeing memory
Date: Tue, 20 Aug 2013 09:52:30 -0400 [thread overview]
Message-ID: <20130820135230.GA32370@sigill.intra.peff.net> (raw)
In-Reply-To: <878uzw7a6l.fsf@linux-k42r.v.cablecom.net>
On Tue, Aug 20, 2013 at 03:40:02PM +0200, Thomas Rast wrote:
> Stefan Beller <stefanbeller@googlemail.com> writes:
>
> > The condition as it is written in that line was most likely intended to
> > check for the pointer passed to free(), rather than checking for the
> > 'repo_abbrev', which is already checked against being non null at the
> > beginning of the function.
> [...]
> > - if (repo_abbrev)
> > + if (*repo_abbrev)
> > free(*repo_abbrev);
>
> But now the test is useless, because free(NULL) is defined to be a
> no-op.
Yeah, I think we should just drop the conditional completely.
I am not sure of the complete back-story. The earlier check for
repo_abbrev to be non-NULL was added by 8503ee4, after this check on
free() already existed. So that was when this conditional became
redundant.
But the line right after this one unconditionally assigns to
"*repo_abbrev", so we would always segfault in such a case anyway (which
is what 8503ee4 was fixing).
So I think it was either a misguided "don't pass NULL to free" check
that was simply wrong, or it was an incomplete "make sure repo_abbrev is
not NULL" check. And the first is useless, and the second is now
redundant due to 8503ee4. So it should simply be free().
-Peff
next prev parent reply other threads:[~2013-08-20 13:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 13:22 [PATCH] mailmap: fix check for freeing memory Stefan Beller
2013-08-20 13:40 ` Thomas Rast
2013-08-20 13:52 ` Jeff King [this message]
2013-08-20 14:17 ` Stefan Beller
2013-08-20 14:18 ` [PATCH] mailmap: remove redundant " Stefan Beller
2013-08-20 14:28 ` Jeff King
2013-08-20 14:23 ` [PATCH] mailmap: fix " Thomas Rast
2013-08-20 14:38 ` Stefan Beller
2013-08-20 16:12 ` Jeff King
2013-08-20 17:18 ` Junio C Hamano
2013-08-20 17:45 ` Jeff King
2013-08-20 14:27 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130820135230.GA32370@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=stefanbeller@googlemail.com \
--cc=trast@inf.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).