wchar/lib_ungetwc: fix the array access out of bounds error

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit is contained in:
guoshichao 2024-04-25 17:40:43 +08:00 committed by Xiang Xiao
parent 9876b0b615
commit ca1e007a22

View File

@ -70,7 +70,7 @@ wint_t ungetwc_unlocked(wint_t wc, FAR FILE *f)
/* Try conversion early so we can fail without locking if invalid */
if ((l = wctomb(mbc, wc)) < 0)
if ((l = wctomb(mbc, wc)) <= 0)
{
return WEOF;
}