From: Ezio Melotti Date: Sat, 3 Nov 2012 21:05:18 +0000 (+0200) Subject: #16336: merge with 3.3. X-Git-Tag: v3.4.0a1~2094^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e58ae44dfb60c6cb87a072498a68eb10e416279;p=thirdparty%2FPython%2Fcpython.git #16336: merge with 3.3. --- 1e58ae44dfb60c6cb87a072498a68eb10e416279 diff --cc Python/codecs.c index 5cfb1c90014e,fd67d1b9e183..37ae41b1ca43 --- a/Python/codecs.c +++ b/Python/codecs.c @@@ -791,13 -791,13 +791,13 @@@ PyCodec_SurrogatePassErrors(PyObject *e /* Try decoding a single surrogate character. If there are more, let the codec call us again. */ p += start; - if (strlen(p) > 2 && - ((p[0] & 0xf0) == 0xe0 || - (p[1] & 0xc0) == 0x80 || - (p[2] & 0xc0) == 0x80)) { + if (PyBytes_GET_SIZE(object) - start >= 3 && + (p[0] & 0xf0) == 0xe0 && + (p[1] & 0xc0) == 0x80 && + (p[2] & 0xc0) == 0x80) { /* it's a three-byte code */ ch = ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f); - if (ch < 0xd800 || ch > 0xdfff) + if (!Py_UNICODE_IS_SURROGATE(ch)) /* it's not a surrogate - fail */ ch = 0; }