From b5a09ebb3f97c24de803429bd585d8a0e0a8aeaf Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 22 Apr 2025 09:02:54 -0300 Subject: [PATCH] libio: Fix UB __libio_codecvt_length To avoid a 0 size VLA. --- libio/iofwide.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libio/iofwide.c b/libio/iofwide.c index c00b83c703..e9d6e51ac7 100644 --- a/libio/iofwide.c +++ b/libio/iofwide.c @@ -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]; -- 2.47.2