[PATCH] parser: Fix PEOF infinite loop in getmbc

Herbert Xu <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Bail out of getmbc if the first character is PEOF.

Fixes: 6c44f4ee0c2b ("parser: Add support for multi-byte characters")
Signed-off-by: Herbert Xu <[email protected]>
---
 src/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.39.2

-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.