Skip to content

Commit

Permalink
Protect peel_ref fallback case from NULL parse_object result
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
spearce authored and gitster committed Feb 24, 2008
1 parent 6c0f869 commit 8c87dc7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8c87dc7

Please sign in to comment.