Re: Incorrect assert in libpqwalreceiver - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Incorrect assert in libpqwalreceiver
Date
Msg-id 7a292c55-854a-4de8-8e94-d259bbb89299@iki.fi
Whole thread Raw
In response to Incorrect assert in libpqwalreceiver  (Jacob Brazeal <jacob.brazeal@gmail.com>)
List pgsql-hackers
On 09/03/2025 10:09, Jacob Brazeal wrote:
> The libpqrcv_connect function asserts 'Assert(i < sizeof(keys))', where 
> keys is declared as const char *keys[6];.
> 
> However, sizeof(keys) is not the correct way to check the array length 
> (on my system, for example, it's 48 = 6 * 8 at this callsite, not 6.)
> 
> I attached a patch to fix the assert, but I suppose we could also just 
> remove the assert altogether, since it hasn't been doing anything for at 
> least 8 years.

Committed, thanks!

I think it's still valuable; it's an easy mistake to make, to add a 
parameter and forget to increase the array size.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: maintenance_work_mem = 64kB doesn't work for vacuum
Next
From: Oliver Ford
Date:
Subject: Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options