Re: Fixes bug in strlower_libc_sb() - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Fixes bug in strlower_libc_sb()
Date
Msg-id aScnhfrMQ5r444GU@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Fixes bug in strlower_libc_sb()  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
Hi,

On Tue, Nov 25, 2025 at 01:50:42PM +0800, Chao Li wrote:
> On Tue, Nov 25, 2025 at 11:03 AM Chao Li <li.evan.chao@gmail.com> wrote:
> 
> > Hi Hackers,
> >
> > While reviewing Jeff's patch [1], I found this bug in strlower_libc_sb():
> >
> > ```
> > static size_t
> > strlower_libc_sb(char *dest, size_t destsize, const char *src, ssize_t
> > srclen,
> > pg_locale_t locale)
> > {
> > if (srclen < 0)
> > srclen = strlen(src);

Nice catch!

FWIW this thread gave me the idea to create a coccinelle script to detect dead
branches [1]. It reports 4 more that are false positives, so I don't think there
is more dead branches in the code tree.

[1]: https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/dead_branches.cocci

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [buildfarm related] Machines gcc experimental failed test_lfind
Next
From: Tomas Vondra
Date:
Subject: Re: Adding basic NUMA awareness