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:
parent
24d4d38c0b
commit
27e27ee224
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user