1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-24 16:36:21 +02:00

Protect peel_ref fallback case from NULL parse_object result

If the SHA-1 we are requesting the object for does not exist in
the object database we get a NULL back.  Accessing the type from
that is not likely to succeed on any system.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Shawn O. Pearce 2008-02-24 03:07:19 -05:00 committed by Junio C Hamano
parent 6c0f86943e
commit 8c87dc77ae

2
refs.c
View File

@ -506,7 +506,7 @@ int peel_ref(const char *ref, unsigned char *sha1)
/* fallback - callers should not call this for unpacked refs */
o = parse_object(base);
if (o->type == OBJ_TAG) {
if (o && o->type == OBJ_TAG) {
o = deref_tag(o, ref, 0);
if (o) {
hashcpy(sha1, o->sha1);