]> git.proxmox.com Git - libgit2.git/commitdiff
Bugfix: Return NULL in push_leaf, when trie is full
authorAxel Wagner <mail@merovius.de>
Wed, 22 May 2013 00:04:12 +0000 (02:04 +0200)
committerAxel Wagner <mail@merovius.de>
Wed, 22 May 2013 00:04:12 +0000 (02:04 +0200)
os->full was set 1, but the overflowed idx_leaf was still used to index
into os->nodes a little later. Returning NULL fixes that.

src/oid.c

index e74640c5776db0e7730ba07c8e632c1091907024..0b023ddd0ff7261c577020c029877b910afdead5 100644 (file)
--- a/src/oid.c
+++ b/src/oid.c
@@ -269,8 +269,10 @@ static trie_node *push_leaf(git_oid_shorten *os, node_index idx, int push_at, co
 
        idx_leaf = (node_index)os->node_count++;
 
-       if (os->node_count == SHRT_MAX)
+       if (os->node_count == SHRT_MAX) {
                os->full = 1;
+        return NULL;
+    }
 
        node = &os->nodes[idx];
        node->children[push_at] = -idx_leaf;