bpo-24214: Fixed the UTF-8 incremental decoder. (GH-12603) (GH-12627)

The bug occurred when the encoded surrogate character is passed
to the incremental decoder in two chunks.
(cherry picked from commit 7a465cb5ee)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-03-30 06:52:41 -07:00 committed by Serhiy Storchaka
parent 4724ba9b57
commit bd48280cb6
3 changed files with 14 additions and 0 deletions

View file

@ -4890,6 +4890,9 @@ PyUnicode_DecodeUTF8Stateful(const char *s,
case 2:
case 3:
case 4:
if (s == end || consumed) {
goto End;
}
errmsg = "invalid continuation byte";
startinpos = s - starts;
endinpos = startinpos + ch - 1;