Skip to content

Commit

Permalink
parse_object_buffer: don't ignore errors from the object specific par…
Browse files Browse the repository at this point in the history
…sing functions

In the case of an malformed object, the object specific parsing functions
would return an error, which is currently ignored. The object can be partial
initialized in this case.

This patch make parse_object_buffer propagate such errors.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Martin Koegler authored and Junio C Hamano committed Feb 4, 2008
1 parent d4fe07f commit d0b8c9e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,25 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
if (type == OBJ_BLOB) {
struct blob *blob = lookup_blob(sha1);
if (blob) {
parse_blob_buffer(blob, buffer, size);
if (parse_blob_buffer(blob, buffer, size))
return NULL;
obj = &blob->object;
}
} else if (type == OBJ_TREE) {
struct tree *tree = lookup_tree(sha1);
if (tree) {
obj = &tree->object;
if (!tree->object.parsed) {
parse_tree_buffer(tree, buffer, size);
if (parse_tree_buffer(tree, buffer, size))
return NULL;
eaten = 1;
}
}
} else if (type == OBJ_COMMIT) {
struct commit *commit = lookup_commit(sha1);
if (commit) {
parse_commit_buffer(commit, buffer, size);
if (parse_commit_buffer(commit, buffer, size))
return NULL;
if (!commit->buffer) {
commit->buffer = buffer;
eaten = 1;
Expand All @@ -165,7 +168,8 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
} else if (type == OBJ_TAG) {
struct tag *tag = lookup_tag(sha1);
if (tag) {
parse_tag_buffer(tag, buffer, size);
if (parse_tag_buffer(tag, buffer, size))
return NULL;
obj = &tag->object;
}
} else {
Expand Down

0 comments on commit d0b8c9e

Please sign in to comment.