diff mbox series

parser: Fix PEOF infinite loop in getmbc

Message ID ZmVlfDqLvvfdw51t@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series parser: Fix PEOF infinite loop in getmbc | expand

Commit Message

Herbert Xu June 9, 2024, 8:19 a.m. UTC
Bail out of getmbc if the first character is PEOF.

Fixes: 6c44f4ee0c2b ("parser: Add support for multi-byte characters")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 src/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/parser.c b/src/parser.c
index a4d3291..3d21894 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -892,7 +892,7 @@  unsigned getmbc(int c, char *out, int mode)
 	wchar_t wc;
 	char *mbc;
 
-	if (likely(c >= 0))
+	if (likely(c >= 0 || c <= PEOF))
 		return 0;
 
 	mbc = (mode & 3) < 2 ? out + 2 + (mode == 1) : out;