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

[PATCH] parse_tag: fail, if tagged objected would be NULL

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Feb 16, 2008, 13:04 UTC
Message-ID
<12031670802582-git-send-email-mkoegler@auto.tuwien.ac.at>
The cause of a NULL in tag->tagged can be:
* a unknown object type is used
* the tag points to a object with an other type as stated
  in the tag.

Both situations are most likley be caused by a not welformed tag. Catching this error here avoids doing tag->tagged!=NULL checks in the rest of git.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
In my option, this change would simplity many things.
tag.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/tag.c b/tag.c
index 38bf913..96fef70 100644
--- a/tag.c
+++ b/tag.c
@@ -82,8 +82,12 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
 	} else {
 		error("Unknown type %s", type);
 		item->tagged = NULL;
+		return -1;
 	}
 
+	if (!item->tagged)
+		return -1;
+
 	if (item->tagged && track_object_refs) {
 		struct object_refs *refs = alloc_object_refs(1);
 		refs->ref[0] = item->tagged;
-- 
1.5.4.1.gcb4c5
Next: Junio C Hamano
Message 1 of 3 in “parse_tag: fail, if tagged objected would be NULL”
  1. parse_tag: fail, if tagged objected would be NULLMartin Koegler, Feb 16, 2008
  2. Junio C HamanoFeb 16, 2008
  3. Martin KoeglerFeb 17, 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.