From: Petr Baudis Date: Wed, 02 Nov 2005 20:07:52 GMT Subject: [PATCH] Fix segfaults caused by invalid tags Message-ID: <20051102200751.26904.5780.stgit@machine.or.cz> On many places, we didn't bother checking deref_tag() return value against NULL, causing GIT segfaulting e.g. on some old Cogito checkouts containing residual tags from GIT. Signed-off-by: Petr Baudis --- fetch-pack.c | 2 +- server-info.c | 5 +++-- upload-pack.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 3df9911..1fae211 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -40,7 +40,7 @@ static int rev_list_insert_ref(const cha { struct object *o = deref_tag(parse_object(sha1)); - if (o->type == commit_type) + if (o && o->type == commit_type) rev_list_push((struct commit *)o, SEEN); return 0; diff --git a/server-info.c b/server-info.c index ba53591..8e13c94 100644 --- a/server-info.c +++ b/server-info.c @@ -14,8 +14,9 @@ static int add_info_ref(const char *path fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path); if (o->type == tag_type) { o = deref_tag(o); - fprintf(info_ref_fp, "%s %s^{}\n", - sha1_to_hex(o->sha1), path); + if (o) + fprintf(info_ref_fp, "%s %s^{}\n", + sha1_to_hex(o->sha1), path); } return 0; } diff --git a/upload-pack.c b/upload-pack.c index c5eff21..f0b8e63 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -227,7 +227,8 @@ static int send_ref(const char *refname, } if (o->type == tag_type) { o = deref_tag(o); - packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname); + if (o) + packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname); } return 0; }