@matheusbsbs / matheus-bagliano / commits / d0b8c9e561
Fork 0

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 <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Koegler committed Feb 3, 2008 at 22:22 UTC d0b8c9e561ea427104611bf392598a398c18d7cb
1 file changed +8 -4
object.c
+8 -4
@@ -140,7 +140,8 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
140 if (type == OBJ_BLOB) {
141 struct blob *blob = lookup_blob(sha1);
142 if (blob) {
143 - parse_blob_buffer(blob, buffer, size);
143 + if (parse_blob_buffer(blob, buffer, size))
144 + return NULL;
145 obj = &blob->object;
146 }
147 } else if (type == OBJ_TREE) {
@@ -148,14 +149,16 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
149 if (tree) {
150 obj = &tree->object;
151 if (!tree->object.parsed) {
151 - parse_tree_buffer(tree, buffer, size);
152 + if (parse_tree_buffer(tree, buffer, size))
153 + return NULL;
154 eaten = 1;
155 }
156 }
157 } else if (type == OBJ_COMMIT) {
158 struct commit *commit = lookup_commit(sha1);
159 if (commit) {
158 - parse_commit_buffer(commit, buffer, size);
160 + if (parse_commit_buffer(commit, buffer, size))
161 + return NULL;
162 if (!commit->buffer) {
163 commit->buffer = buffer;
164 eaten = 1;
@@ -165,7 +168,8 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
168 } else if (type == OBJ_TAG) {
169 struct tag *tag = lookup_tag(sha1);
170 if (tag) {
168 - parse_tag_buffer(tag, buffer, size);
171 + if (parse_tag_buffer(tag, buffer, size))
172 + return NULL;
173 obj = &tag->object;
174 }
175 } else {