Skip to content

Commit ab43e49

Browse files
committed
blame: check return value from read_sha1_file()
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0058a33 commit ab43e49

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

builtin-blame.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file)
9898
num_read_blob++;
9999
file->ptr = read_sha1_file(o->blob_sha1, &type,
100100
(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);
101105
o->file = *file;
102106
}
103107
else
@@ -1384,6 +1388,9 @@ static void get_commit_info(struct commit *commit,
13841388
unsigned long size;
13851389
commit->buffer =
13861390
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));
13871394
}
13881395
ret->author = author_buf;
13891396
get_ac_line(commit->buffer, "\nauthor ",
@@ -2382,6 +2389,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
23822389

23832390
sb.final_buf = read_sha1_file(o->blob_sha1, &type,
23842391
&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);
23852396
}
23862397
num_read_blob++;
23872398
lno = prepare_lines(&sb);

0 commit comments

Comments
 (0)