tree-diff: don't access hash of NULL object_id pointer
[gitweb.git] / shallow.c
index 6950cc24f02bd03480321eeaa0a36a32a460ed99..ef7ca78993df20082c858a7d2b8c7094fcbd1590 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -473,11 +473,15 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
        struct commit_list *head = NULL;
        int bitmap_nr = (info->nr_bits + 31) / 32;
        size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
-       uint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */
-       uint32_t *bitmap = paint_alloc(info);
        struct commit *c = lookup_commit_reference_gently(oid, 1);
+       uint32_t *tmp; /* to be freed before return */
+       uint32_t *bitmap;
+
        if (!c)
                return;
+
+       tmp = xmalloc(bitmap_size);
+       bitmap = paint_alloc(info);
        memset(bitmap, 0, bitmap_size);
        bitmap[id / 32] |= (1U << (id % 32));
        commit_list_insert(c, &head);