libio: Fix UB __libio_codecvt_length

To avoid a 0 size VLA.
This commit is contained in:
Adhemerval Zanella 2025-04-22 09:02:54 -03:00
parent 43ba3b5c3a
commit b5a09ebb3f
1 changed files with 3 additions and 0 deletions

View File

@ -228,6 +228,9 @@ __libio_codecvt_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
const char *from_start, const char *from_end,
size_t max)
{
if (max == 0)
return 0;
int result;
const unsigned char *cp = (const unsigned char *) from_start;
wchar_t to_buf[max];