Skip to content

Commit fd419ec

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 c69baaf commit fd419ec

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

object-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,9 +1298,9 @@ static int index_mem(struct index_state *istate,
12981298
fsck_options_init(&opts, the_repository, FSCK_OPTIONS_DEFAULT);
12991299
opts.strict = 1;
13001300
opts.error_func = hash_format_check_report;
1301-
if (fsck_buffer(null_oid(istate->repo->hash_algo), type, buf, size, &opts))
1301+
if (fsck_buffer(null_oid(istate->repo->hash_algo), type, buf, size, &opts) ||
1302+
fsck_finish(&opts))
13021303
die(_("refusing to create malformed object"));
1303-
fsck_finish(&opts);
13041304
}
13051305

13061306
if (write_object)

0 commit comments

Comments
 (0)