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> |
||
|---|---|---|
| .. | ||
| LICENSE | ||
| basics.c | ||
| basics.h | ||
| block.c | ||
| block.h | ||
| blocksource.c | ||
| blocksource.h | ||
| constants.h | ||
| error.c | ||
| fsck.c | ||
| 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-system.h | ||
| reftable-table.h | ||
| reftable-writer.h | ||
| stack.c | ||
| stack.h | ||
| system.c | ||
| system.h | ||
| table.c | ||
| table.h | ||
| tree.c | ||
| tree.h | ||
| writer.c | ||
| writer.h | ||