Re: [PATCH v2 3/9] reftable/stack: fix parameter validation when compacting range
- From
Toon Claes <toon@iotcl.com>
- Date
- Feb 1, 2024, 16:15 UTC
- Message-ID
- <87o7d0p38k.fsf@iotcl.com>
- In-Reply-To
- <f134702dc5f656942baafbd80af46ad928ee1449.1706772591.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 24 quoted lines
> diff --git a/reftable/stack.c b/reftable/stack.c
> index d084823a92..b6b24c90bf 100644
> --- a/reftable/stack.c
> +++ b/reftable/stack.c
> @@ -1146,12 +1146,14 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
> done:
> free_names(delete_on_success);
>
> - listp = subtable_locks;
> - while (*listp) {
> - unlink(*listp);
> - listp++;
> + if (subtable_locks) {
> + listp = subtable_locks;
> + while (*listp) {
> + unlink(*listp);
> + listp++;
> + }
> + free_names(subtable_locks);
> }
> - free_names(subtable_locks);
> if (lock_file_fd >= 0) {
> close(lock_file_fd);
> lock_file_fd = -1;Technically, this change is not needed, because `free_names()` deals with NULL pointers already.
-- Toon