Skip to content

Commit 2e3404c

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builtin-pack-objects.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,13 +1356,19 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
13561356
/* Load data if not already done */
13571357
if (!trg->data) {
13581358
trg->data = read_sha1_file(trg_entry->idx.sha1, &type, &sz);
1359+
if (!trg->data)
1360+
die("object %s cannot be read",
1361+
sha1_to_hex(trg_entry->idx.sha1));
13591362
if (sz != trg_size)
13601363
die("object %s inconsistent object length (%lu vs %lu)",
13611364
sha1_to_hex(trg_entry->idx.sha1), sz, trg_size);
13621365
window_memory_usage += sz;
13631366
}
13641367
if (!src->data) {
13651368
src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
1369+
if (!src->data)
1370+
die("object %s cannot be read",
1371+
sha1_to_hex(src_entry->idx.sha1));
13661372
if (sz != src_size)
13671373
die("object %s inconsistent object length (%lu vs %lu)",
13681374
sha1_to_hex(src_entry->idx.sha1), sz, src_size);

0 commit comments

Comments
 (0)