git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Carlos Martín Nieto" <cmn@elego.de>
Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
	git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] branch: don't assume the merge filter ref exists
Date: Mon, 27 Feb 2012 14:30:44 -0500	[thread overview]
Message-ID: <20120227193044.GD1600@sigill.intra.peff.net> (raw)
In-Reply-To: <1330355513-22351-1-git-send-email-cmn@elego.de>

On Mon, Feb 27, 2012 at 04:11:53PM +0100, Carlos Martín Nieto wrote:

> print_ref_list looks up the merge_filter_ref and assumes that a valid
> pointer is returned. When the object doesn't exist, it tries to
> dereference a NULL pointer. This can be the case when git branch
> --merged is given an argument that isn't a valid commit name.
> 
> Check whether the lookup returns a NULL pointer and die with an error
> if it does. Add a test, while we're at it.
> 
> Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
> ---
> 
> It certainly looks like --merged was only ever supposed to be used
> with branch names, as it assumed that get_sha1() would catch the
> errors.
> 
> I'm not sure if "bad object" or "invalid object" fits better. "bad
> object" might have a stronger implication that it exists but is
> corrupt.

You would also get NULL if the object exists but is not a commit. Maybe:

  die("object '%s' does not point to a commit", ...)

would be better? It covers the wrong-type case, and is still technically
true when the object does not exist.

-Peff

  parent reply	other threads:[~2012-02-27 19:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 12:26 [BUG] git branch --merged $unknown_checksum segfaults Bernhard Reutner-Fischer
2012-02-27 15:11 ` [PATCH] branch: don't assume the merge filter ref exists Carlos Martín Nieto
2012-02-27 18:05   ` Junio C Hamano
2012-02-27 19:30   ` Jeff King [this message]
2012-02-27 19:33     ` Junio C Hamano
2012-02-27 19:43       ` Jeff King
2012-02-28 15:14         ` Carlos Martín Nieto
2012-02-28 17:32           ` Junio C Hamano

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=20120227193044.GD1600@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=cmn@elego.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rep.dot.nop@gmail.com \
    /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).