peel_onion: handle NULL
[gitweb.git] / sha1_name.c
index 4c0bc9c5b5d5257195ee676fe46d1d9129daf7e8..2575ea77f499f8316064c1c96927f391130946a7 100644 (file)
@@ -494,8 +494,11 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
                                return error("%.*s: expected %s type, but the object dereferences to %s type",
                                             len, name, typename(expected_type),
                                             typename(o->type));
+                       if (!o)
+                               return -1;
                        if (!o->parsed)
-                               parse_object(o->sha1);
+                               if (!parse_object(o->sha1))
+                                       return -1;
                }
        }
        return 0;