]> git.99rst.org Git - git.git/commit
reftable/merged: fix zero-sized allocation when there are no readers
authorPatrick Steinhardt <redacted>
Sun, 22 Dec 2024 07:24:29 +0000 (08:24 +0100)
committerJunio C Hamano <redacted>
Sun, 22 Dec 2024 08:58:23 +0000 (00:58 -0800)
commit5ab83521cfe687e4295f5748f2c5d2aa7477efe5
treeb76270681a8dac7c2ff4e3deb39b96297541e979
parent8e27ee9220883cf5a0629c752e1642daaba4ce14
reftable/merged: fix zero-sized allocation when there are no readers

It was reported [1] that Git started to fail with an out-of-memory error
when initializing repositories with the reftable backend on NonStop
platforms. A bisect led to 802c0646ac (reftable/merged: handle
allocation failures in `merged_table_init_iter()`, 2024-10-02), which
changed how we allocate memory when initializing a merged table.

The root cause of this seems to be that NonStop returns a `NULL` pointer
when doing a zero-sized allocation. This would've already happened
before the above change, but we never noticed because we did not check
the result. Now we do notice and thus return an out-of-memory error to
the caller.

Fix the issue by skipping the allocation altogether in case there are no
readers.

[1]: <redacted>

Reported-by: Randall S. Becker <redacted>
Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
reftable/merged.c
git clone https://git.99rst.org/PROJECT