bpo-24214: Fixed the UTF-8 incremental decoder. (GH-12603)
The bug occurred when the encoded surrogate character is passed
to the incremental decoder in two chunks.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 8ab3943..c0b345b 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4883,6 +4883,9 @@
case 2:
case 3:
case 4:
+ if (s == end || consumed) {
+ goto End;
+ }
errmsg = "invalid continuation byte";
startinpos = s - starts;
endinpos = startinpos + ch - 1;