git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] parse_object_buffer: don't ignore errors from the object specific parsing functions

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Feb 3, 2008, 21:22 UTC
Message-ID
<12020737603543-git-send-email-mkoegler@auto.tuwien.ac.at>
In-Reply-To
<12020737601683-git-send-email-mkoegler@auto.tuwien.ac.at>

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>
---
 object.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/object.c b/object.c
index 5a5ebe2..4e7f27a 100644
--- a/object.c
+++ b/object.c
@@ -140,7 +140,8 @@ 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) {
@@ -148,14 +149,16 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
 		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;
@@ -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 {
-- 
1.5.4.g22bc
Previous: Martin KoeglerNext: Junio C Hamano
Message 3 of 7 in “git-fsck: report missing author/commit line in a commit as an error”
  1. 1/3 git-fsck: report missing author/commit line in a commit as an errorMartin Koegler, Feb 3, 2008
  2. 2/3 fsck_commit: remove duplicate testsMartin Koegler, Feb 3, 2008
  3. 3/3 parse_object_buffer: don't ignore errors from the object specific parsing functionsMartin Koegler, Feb 3, 2008
  4. Junio C HamanoFeb 3, 2008
  5. Johannes SchindelinFeb 4, 2008
  6. Martin KoeglerFeb 4, 2008
  7. Junio C HamanoFeb 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.