| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Jeff Davis <pgsql(at)j-davis(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: A few pg_locale.c fixes |
| Date: | 2026-01-28 22:59:02 |
| Message-ID: | 921C7BF4-5349-4730-A8BD-55C5427A5713@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jan 29, 2026, at 03:37, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
>
> Attached patches.
>
> Problems found with AI assistance. Patches by me.
>
> Regards,
> Jeff Davis
>
> <v1-0001-Fix-memory-leaks-in-pg_locale_libc.c.patch><v1-0002-Fix-memory-leaks-in-pg_locale_icu.c.patch><v1-0003-pg_locale.c-Clean-up-srclen-1.patch>
0001 and 0002 looks good.
For 0003, I see some other functions having header comment to explain what -1 of length means, do we want to add the explanation to these two functions’ header comments?
```
/* 'srclen' of -1 means the strings are NUL-terminated */
size_t
strnxfrm_icu(char *dest, size_t destsize, const char *src, ssize_t srclen,
pg_locale_t locale)
```
Whiling reviewing 0001, I noticed the other problem:
```
/*
* char2wchar --- convert multibyte characters to wide characters
*
* This has almost the API of mbstowcs_l(), except that *from need not be
* null-terminated; instead, the number of input bytes is specified as
* fromlen. Also, we ereport() rather than returning -1 for invalid
* input encoding. tolen is the maximum number of wchar_t's to store at *to.
* The output will be zero-terminated iff there is room.
*/
static size_t
char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen,
locale_t loc)
{
size_t result;
if (result == -1)
{
```
This function’s return type is size_t that is unsigned, but the header comment says it may return -1.
Also, result is of type size_t, but it is check against -1.
If you confirm that is a problem, you may include a fix in this patch set as well.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-01-28 23:13:44 | Re: Correction to comment of brin_range_deserialize |
| Previous Message | Jelte Fennema-Nio | 2026-01-28 22:48:34 | Re: trivial designated initializers |