aboutsummaryrefslogtreecommitdiff
path: root/reftable/stack_test.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-02-06 07:35:31 +0100
committerJunio C Hamano <gitster@pobox.com>2024-02-06 12:10:08 -0800
commitca63af0a248d31bf917d207722b284da41ffcee7 (patch)
tree44641c8942ae97300fae36bcea3c60a1d7d1ff28 /reftable/stack_test.c
parentb4ff12c8eefff9cba73ba3cb7492111adfa31d87 (diff)
downloadgit-ca63af0a248d31bf917d207722b284da41ffcee7.tar.xz
reftable/stack: fix parameter validation when compacting range
The `stack_compact_range()` function receives a "first" and "last" index that indicates which tables of the reftable stack should be compacted. Naturally, "first" must be smaller than "last" in order to identify a proper range of tables to compress, which we indeed also assert in the function. But the validations happens after we have already allocated arrays with a size of `last - first + 1`, leading to an underflow and thus an invalid allocation size. Fix this by reordering the array allocations to happen after we have validated parameters. While at it, convert the array allocations to use the newly introduced macros. Note that the relevant variables pointing into arrays should also be converted to use `size_t` instead of `int`. This is left for a later commit in this series. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/stack_test.c')
0 files changed, 0 insertions, 0 deletions