Commit 52f537e9c540fe5492ee6008153ab4db50c4091e

Axel Wagner 2013-05-22T02:04:12

Bugfix: Return NULL in push_leaf, when trie is full 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/oid.c b/src/oid.c
index e74640c..0b023dd 100644
--- 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;