@matheusbsbs / matheus-bagliano / commits / ab43e495dd
Fork 0

blame: check return value from read_sha1_file()

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 25, 2007 at 01:26 UTC ab43e495dd095547c3ada9ae13b72f9741a7f0d2
1 file changed +11
builtin-blame.c
+11
@@ -98,6 +98,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file)
98 num_read_blob++;
99 file->ptr = read_sha1_file(o->blob_sha1, &type,
100 (unsigned long *)(&(file->size)));
101 + if (!file->ptr)
102 + die("Cannot read blob %s for path %s",
103 + sha1_to_hex(o->blob_sha1),
104 + o->path);
105 o->file = *file;
106 }
107 else
@@ -1384,6 +1388,9 @@ static void get_commit_info(struct commit *commit,
1388 unsigned long size;
1389 commit->buffer =
1390 read_sha1_file(commit->object.sha1, &type, &size);
1391 + if (!commit->buffer)
1392 + die("Cannot read commit %s",
1393 + sha1_to_hex(commit->object.sha1));
1394 }
1395 ret->author = author_buf;
1396 get_ac_line(commit->buffer, "\nauthor ",
@@ -2382,6 +2389,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2389
2390 sb.final_buf = read_sha1_file(o->blob_sha1, &type,
2391 &sb.final_buf_size);
2392 + if (!sb.final_buf)
2393 + die("Cannot read blob %s for path %s",
2394 + sha1_to_hex(o->blob_sha1),
2395 + path);
2396 }
2397 num_read_blob++;
2398 lno = prepare_lines(&sb);