Re: Small patch to improve safety of utf8_to_unicode(). - Mailing list pgsql-hackers

From Chao Li
Subject Re: Small patch to improve safety of utf8_to_unicode().
Date
Msg-id 313BCA0E-2E74-4EB6-9AA8-10DB7F439151@gmail.com
Whole thread
In response to Re: Small patch to improve safety of utf8_to_unicode().  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Small patch to improve safety of utf8_to_unicode().
List pgsql-hackers

> On Jun 24, 2026, at 13:45, Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Mon, 2026-06-22 at 19:02 -0700, Jeff Davis wrote:
>> v4 attached.
>
> v5 attached.
>
> There's an extra patch 0002 to fix a logic bug when handling final
> sigma (only affects the builtin pg_unicode_fast locale), which I think
> should be backported to 18.
>
> Also added tests.
>
> Regards,
> Jeff Davis
>
>
<v5-0001-unicode_case.c-defend-against-invalid-UTF8.patch><v5-0002-pg_unicode_fast-fix-final-sigma-logic.patch><v5-0003-unicode_case.c-change-API-to-signal-UTF8-decoding.patch><v5-0004-Validating-iterator-friendly-UTF8-encoder-decoder.patch><v5-0005-unicode_case.c-use-new-utf8encode-utf8decode-APIs.patch>

There is a compile warning against pg_wchar.h in 0004:
```
../../../src/include/mb/pg_wchar.h:523:11: warning: variable 'codepoint' is used uninitialized whenever 'if' condition
isfalse [-Wsometimes-uninitialized] 
  523 |         else if (nbytes == 4)
      |                  ^~~~~~~~~~~
../../../src/include/mb/pg_wchar.h:540:16: note: uninitialized use occurs here
  540 |         *pcodepoint = codepoint;
      |                       ^~~~~~~~~
../../../src/include/mb/pg_wchar.h:523:7: note: remove the 'if' if its condition is always true
  523 |         else if (nbytes == 4)
      |              ^~~~~~~~~~~~~~~~
  524 |         {
../../../src/include/mb/pg_wchar.h:469:20: note: initialize the variable 'codepoint' to silence this warning
  469 |         char32_t        codepoint;
      |                                  ^
      |                                   = 0
1 warning generated.
```

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: Reject unsupported COPY FROM targets before analyzing WHERE clause
Next
From: Peter Eisentraut
Date:
Subject: Re: FOR PORTION OF should reject GENERATED columns