Re: Fixes bug in strlower_libc_sb()
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Jeff Davis <pgsql@j-davis.com>
Date: 2025-11-26T16:15:01Z
Lists: 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
Commits
-
Remove a useless length check.
- 3b9c11892058 19 (unreleased) landed