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>
Shawn O. Pearce committed
Feb 24, 2008 at 03:07 UTC
8c87dc77ae45d7277001b1be2c88ea9062e11d72
1 file changed
+1
-1
refs.c
+1
-1
@@ -506,7 +506,7 @@ int peel_ref(const char *ref, unsigned char *sha1)
506
507
/* fallback - callers should not call this for unpacked refs */
508
o = parse_object(base);
509
- if (o->type == OBJ_TAG) {
509
+ if (o && o->type == OBJ_TAG) {
510
o = deref_tag(o, ref, 0);
511
if (o) {
512
hashcpy(sha1, o->sha1);