Hello Thomas,
In curses/widechar/charable.c there is this fragment of code:
...
char temp[MB_LEN_MAX];
result = wctomb(temp, ch);
if (strlen(temp) == 1)
...
But wctomb() does not nul-terminate the string of bytes produced in
`temp`, so calling strlen() on it does not give the number of these
bytes. Nor is there any need for it -- `result` already contains
that number.
Patch is attached. (But if it were up to me, I would elide the entire
`result` variable.)
Benno
--- ncurses/widechar/charable.c.was 2025-08-31 13:49:27.510832095 +0200
+++ ncurses/widechar/charable.c 2025-08-31 13:50:15.294242167 +0200
@@ -54,7 +54,7 @@
#elif HAVE_WCTOMB
char temp[MB_LEN_MAX];
result = wctomb(temp, ch);
- if (strlen(temp) == 1)
+ if (result == 1)
result = UChar(temp[0]);
else
result = -1;
OpenPGP_signature.asc
Description: OpenPGP digital signature
