Commit a02fc2cd by Carlos Martín Nieto Committed by Vicent Marti

index: correctly parse invalidated TREE extensions

A TREE extension with an entry count of -1 means that it was
invalidated and we should ignore it. Do so instead of returning an
error.

This fixes issue #202

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent cdd9fd47
...@@ -520,11 +520,20 @@ static int read_tree_internal(git_index_tree **out, ...@@ -520,11 +520,20 @@ static int read_tree_internal(git_index_tree **out,
/* Blank-terminated ASCII decimal number of entries in this tree */ /* Blank-terminated ASCII decimal number of entries in this tree */
if (git__strtol32(&count, buffer, &buffer, 10) < GIT_SUCCESS || if (git__strtol32(&count, buffer, &buffer, 10) < GIT_SUCCESS ||
count < 0) { count < -1) {
error = GIT_EOBJCORRUPTED; error = GIT_EOBJCORRUPTED;
goto exit; goto exit;
} }
/* Invalidated TREE. Free the tree but report success */
if (count == -1) {
buffer = buffer_end;
free_tree(tree); /* Needs to be done manually */
tree = NULL;
error = GIT_SUCCESS;
goto exit;
}
tree->entries = (size_t)count; tree->entries = (size_t)count;
if (*buffer != ' ' || ++buffer >= buffer_end) { if (*buffer != ' ' || ++buffer >= buffer_end) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment