parser: Fix OOB read when formatting error message

Don't try to print characters beyond the end of the buffer.

Found by OSS-Fuzz.

Bug: http://b/261365944
Test: TreeHugger
Change-Id: I8324497a4755cd66145ab9d109c349ca4703fa98
diff --git a/parser.c b/parser.c
index 506c78a..f11f017 100644
--- a/parser.c
+++ b/parser.c
@@ -12170,7 +12170,11 @@
 #endif
     return(ret);
 encoding_error:
-    {
+    if (ctxt->input->end - ctxt->input->cur < 4) {
+	__xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
+		     "Input is not proper UTF-8, indicate encoding !\n",
+		     NULL, NULL);
+    } else {
         char buffer[150];
 
 	snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",