reftable: fix resource leak blocksource.c

This would be triggered in the unlikely event of fstat() failing on an
opened file.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Han-Wen Nienhuys 2022-01-20 15:12:02 +00:00 committed by Junio C Hamano
parent 24d4d38c0b
commit 27e27ee224

View file

@ -134,8 +134,10 @@ int reftable_block_source_from_file(struct reftable_block_source *bs,
}
err = fstat(fd, &st);
if (err < 0)
return -1;
if (err < 0) {
close(fd);
return REFTABLE_IO_ERROR;
}
p = reftable_calloc(sizeof(struct file_block_source));
p->size = st.st_size;