Commit 2218fd57a50ceb851cb131939bf0747e072e40f6

Carlos Martín Nieto 2012-04-20T02:23:14

tree-cache: don't error out on a childless invalidated entry The code used to assume that there had to be data after the newline in a tree cache extension entry. This isn't true for a childless invalidated entry if it's the last one, as there won't be any children nor a hash to take up space. Adapt the off-by-one comparison to also work in this case. Fixes #633.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/tree-cache.c b/src/tree-cache.c
index 10667b1..9baa06a 100644
--- a/src/tree-cache.c
+++ b/src/tree-cache.c
@@ -130,7 +130,7 @@ static int read_tree_internal(git_tree_cache **out,
 
 	tree->children_count = count;
 
-	if (*buffer != '\n' || ++buffer >= buffer_end) {
+	if (*buffer != '\n' || ++buffer > buffer_end) {
 		error = GIT_EOBJCORRUPTED;
 		goto cleanup;
 	}