Skip to content

Commit d0b8c9e

Browse files
Martin Koeglergitster
authored andcommitted
parse_object_buffer: don't ignore errors from the object specific parsing 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4fe07f commit d0b8c9e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

object.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,25 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
140140
if (type == OBJ_BLOB) {
141141
struct blob *blob = lookup_blob(sha1);
142142
if (blob) {
143-
parse_blob_buffer(blob, buffer, size);
143+
if (parse_blob_buffer(blob, buffer, size))
144+
return NULL;
144145
obj = &blob->object;
145146
}
146147
} else if (type == OBJ_TREE) {
147148
struct tree *tree = lookup_tree(sha1);
148149
if (tree) {
149150
obj = &tree->object;
150151
if (!tree->object.parsed) {
151-
parse_tree_buffer(tree, buffer, size);
152+
if (parse_tree_buffer(tree, buffer, size))
153+
return NULL;
152154
eaten = 1;
153155
}
154156
}
155157
} else if (type == OBJ_COMMIT) {
156158
struct commit *commit = lookup_commit(sha1);
157159
if (commit) {
158-
parse_commit_buffer(commit, buffer, size);
160+
if (parse_commit_buffer(commit, buffer, size))
161+
return NULL;
159162
if (!commit->buffer) {
160163
commit->buffer = buffer;
161164
eaten = 1;
@@ -165,7 +168,8 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
165168
} else if (type == OBJ_TAG) {
166169
struct tag *tag = lookup_tag(sha1);
167170
if (tag) {
168-
parse_tag_buffer(tag, buffer, size);
171+
if (parse_tag_buffer(tag, buffer, size))
172+
return NULL;
169173
obj = &tag->object;
170174
}
171175
} else {

0 commit comments

Comments
 (0)