git/reftable
Johannes Schindelin f8121b7479 reftable/block: check deflateInit() return value
block_writer_init() allocates a z_stream and calls deflateInit()
to prepare it for compressing log records. The return value of
deflateInit() is silently discarded. If zlib initialization fails
(e.g., Z_MEM_ERROR when the system is under memory pressure), the
z_stream is left in an undefined state.

Subsequent deflate() calls in block_writer_finish() then operate
on this uninitialized stream. Current zlib/zlib-ng versions handle
such a stream gracefully, by returning `Z_STREAM_ERROR`, so in
practice it would likely not result in catastrophic error.

The function already uses REFTABLE_ZLIB_ERROR for deflate() failures
later in the code path, so returning the same error code for
deflateInit() failure is consistent.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-12 09:05:49 -07:00
..
LICENSE
basics.c
basics.h
block.c reftable/block: check deflateInit() return value 2026-08-12 09:05:49 -07:00
block.h
blocksource.c reftable/system: add abstraction to mmap files 2026-04-02 10:45:44 -07:00
blocksource.h
constants.h
error.c
fsck.c reftable/fsck: use REFTABLE_UNUSED instead of UNUSED 2026-04-02 10:45:43 -07:00
iter.c
iter.h
merged.c
merged.h
pq.c
pq.h
record.c
record.h
reftable-basics.h
reftable-block.h
reftable-blocksource.h
reftable-constants.h
reftable-error.h
reftable-fsck.h
reftable-iterator.h
reftable-merged.h
reftable-record.h
reftable-stack.h reftable: split up write options 2026-06-26 08:27:19 -07:00
reftable-system.h
reftable-table.h
reftable-writer.h reftable: split up write options 2026-06-26 08:27:19 -07:00
stack.c reftable: split up write options 2026-06-26 08:27:19 -07:00
stack.h reftable: split up write options 2026-06-26 08:27:19 -07:00
system.c reftable/system: add abstraction to mmap files 2026-04-02 10:45:44 -07:00
system.h doc: fix typos via codespell 2026-06-08 00:21:35 +09:00
table.c
table.h
tree.c
tree.h
writer.c reftable: handle block-writer initialization errors 2026-08-12 09:05:49 -07:00
writer.h reftable: split up write options 2026-06-26 08:27:19 -07:00