]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/basics: handle allocation failures in `reftable_calloc()`
authorPatrick Steinhardt <ps@pks.im>
Wed, 2 Oct 2024 10:55:35 +0000 (12:55 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Oct 2024 14:53:51 +0000 (07:53 -0700)
commit6593e147d3992eb52cb53b6f8a09dc3e10f79613
tree7d93b153821c5a39affdc921def0e84e64f1d840
parent7f0969febf974f017b92e7152a17c98105583167
reftable/basics: handle allocation failures in `reftable_calloc()`

Handle allocation failures in `reftable_calloc()`.

While at it, remove our use of `st_mult()` that would cause us to die on
an overflow. From the caller's point of view there is not much of a
difference between arguments that are too large to be multiplied and a
request that is too big to handle by the allocator: in both cases the
allocation cannot be fulfilled. And in neither of these cases do we want
the reftable library to die.

While we could use `unsigned_mult_overflows()` to handle the overflow
gracefully, we instead open-code it to further our goal of converting
the reftable codebase to become a standalone library that can be reused
by external projects.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/basics.c