On 2023-07-11 01:24, Bruno Haible wrote:
Based on the comments in gnulib/lib/mbrtoc16.c, I think it should better
clear the first 24, not 12, bytes of the struct. Otherwise it can be in
a state where mbsinit() returns true but the mbrto* functions have
undefined behaviour.

For mbcel all all that matters is mbrtoc32. Could you give an example of the undefined behavior there? I looked at the citrus implementations in current FreeBSD, OpenBSD and macOS and thought that 12 bytes is enough for mbrtoc32 on all their porting targets. NetBSD is a bit different and needs just a pointer width.

I didn't look at other functions like mbrlen and mbsinit, but would be mildly surprised if these functions differed, as mbrtoc32 is the fundamental function.

Assuming the optimization is valid, I suppose we could put it in Gnulib. Though it doesn't help much on GNU/Linux and so is lower priority.

Reply via email to