git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parse_tag: fail, if tagged objected would be NULL
@ 2008-02-16 13:04 Martin Koegler
  2008-02-16 19:13 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Koegler @ 2008-02-16 13:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Martin Koegler

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-17 17:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-16 13:04 [PATCH] parse_tag: fail, if tagged objected would be NULL Martin Koegler
2008-02-16 19:13 ` Junio C Hamano
2008-02-17 17:48   ` Martin Koegler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).