Merge branch 'jk/cache-tree-protect-from-broken-libgit2'
authorJunio C Hamano <gitster@pobox.com>
Thu, 6 Nov 2014 18:51:35 +0000 (10:51 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Nov 2014 18:51:35 +0000 (10:51 -0800)
The code to use cache-tree trusted the on-disk data too much
and fell into an infinite loop.

* jk/cache-tree-protect-from-broken-libgit2:
cache-tree: avoid infinite loop on zero-entry tree

cache-tree.c
index 215202c42d2243ebf704ac083937d65aa8497929..32772b95644d2f32841984b25b685379c6914ad4 100644 (file)
@@ -303,6 +303,8 @@ static int update_one(struct cache_tree *it,
                                    flags);
                if (subcnt < 0)
                        return subcnt;
+               if (!subcnt)
+                       die("index cache-tree records empty sub-tree");
                i += subcnt;
                sub->count = subcnt; /* to be used in the next loop */
                *skip_count += subskip;