Re: [PATCH] branch: don't assume the merge filter ref exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
> ---
> 
> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]