summaryrefslogtreecommitdiff
path: root/reftable
diff options
context:
space:
mode:
authorLibravatar Han-Wen Nienhuys <hanwen@google.com>2022-01-20 15:12:02 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-01-20 11:31:52 -0800
commit27e27ee2249f617b529ac5c9c419d3961885994b (patch)
tree70a1255702ee070abafc74dd1a2fde28ad90478b /reftable
parentreftable: fix resource leak in block.c error path (diff)
downloadtgif-27e27ee2249f617b529ac5c9c419d3961885994b.tar.xz
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>
Diffstat (limited to 'reftable')
-rw-r--r--reftable/blocksource.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/reftable/blocksource.c b/reftable/blocksource.c
index 0044eecd9a..2605371c28 100644
--- a/reftable/blocksource.c
+++ b/reftable/blocksource.c
@@ -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;