Skip to content

Commit 1d8ce9a

Browse files
committed
index_mem(): check return value of fsck_finish()
This would catch problems in blobs that were newly linked to git metafiles (like .gitmodules) by a tree we are checking. We should add a test. Note that fsck_finish() both checks the blobs and frees the memory. So in a short-circuit "||", we'd fail to do that cleanup if fsck_buffer() reports a problem. That's OK in this case because we die(). Maybe this should stay as two separate conditionals.
1 parent 67ad421 commit 1d8ce9a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

object-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,9 +1254,9 @@ static int index_mem(struct index_state *istate,
12541254

12551255
opts.strict = 1;
12561256
opts.error_func = hash_format_check_report;
1257-
if (fsck_buffer(null_oid(istate->repo->hash_algo), type, buf, size, &opts))
1257+
if (fsck_buffer(null_oid(istate->repo->hash_algo), type, buf, size, &opts) ||
1258+
fsck_finish(&opts))
12581259
die(_("refusing to create malformed object"));
1259-
fsck_finish(&opts);
12601260
}
12611261

12621262
if (write_object)

0 commit comments

Comments
 (0)