All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH 1/2] blame: check return value from read_sha1_file()
Date: Sat, 25 Aug 2007 01:30:04 -0700	[thread overview]
Message-ID: <7v7ink6mpf.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20070825072604.GA20155@spearce.org> (Shawn O. Pearce's message of "Sat, 25 Aug 2007 03:26:04 -0400")

(Trivial #1).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-blame.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/builtin-blame.c b/builtin-blame.c
index 0519339..dc88a95 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -98,6 +98,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file)
 		num_read_blob++;
 		file->ptr = read_sha1_file(o->blob_sha1, &type,
 					   (unsigned long *)(&(file->size)));
+		if (!file->ptr)
+			die("Cannot read blob %s for path %s",
+			    sha1_to_hex(o->blob_sha1),
+			    o->path);
 		o->file = *file;
 	}
 	else
@@ -1384,6 +1388,9 @@ static void get_commit_info(struct commit *commit,
 		unsigned long size;
 		commit->buffer =
 			read_sha1_file(commit->object.sha1, &type, &size);
+		if (!commit->buffer)
+			die("Cannot read commit %s",
+			    sha1_to_hex(commit->object.sha1));
 	}
 	ret->author = author_buf;
 	get_ac_line(commit->buffer, "\nauthor ",
@@ -2382,6 +2389,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 
 		sb.final_buf = read_sha1_file(o->blob_sha1, &type,
 					      &sb.final_buf_size);
+		if (!sb.final_buf)
+			die("Cannot read blob %s for path %s",
+			    sha1_to_hex(o->blob_sha1),
+			    path);
 	}
 	num_read_blob++;
 	lno = prepare_lines(&sb);
-- 
1.5.3.rc6.23.g0058

  reply	other threads:[~2007-08-25  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-25  7:26 [PATCH] Don't segfault if we failed to inflate a packed delta Shawn O. Pearce
2007-08-25  8:30 ` Junio C Hamano [this message]
2007-08-25  8:30 ` [PATCH 2/2] pack-objects: check return value from read_sha1_file() Junio C Hamano
2007-08-25 15:19 ` [PATCH] Don't segfault if we failed to inflate a packed delta Linus Torvalds
2007-08-25 17:56   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v7ink6mpf.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.