summaryrefslogtreecommitdiffstats
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2012-10-27 00:05:09 (GMT)
committerPhilip Jenvey <pjenvey@underboss.org>2012-10-27 00:05:09 (GMT)
commit5f9459fbedae091bff5b87189014a996f1352b1c (patch)
tree9f150bf1f8ef9ed039f37f176e46b75bb2b69976 /Python/codecs.c
parent735d31723fb348f08be8fc2677dbb26beac5394a (diff)
parent45c41494bf4992d6c2a0bd1fca3d0dff164ec4ba (diff)
downloadcpython-5f9459fbedae091bff5b87189014a996f1352b1c.zip
cpython-5f9459fbedae091bff5b87189014a996f1352b1c.tar.gz
cpython-5f9459fbedae091bff5b87189014a996f1352b1c.tar.bz2
merge with 3.2
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 797a45f..5470500 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -791,9 +791,10 @@ PyCodec_SurrogatePassErrors(PyObject *exc)
/* Try decoding a single surrogate character. If
there are more, let the codec call us again. */
p += start;
- if ((p[0] & 0xf0) == 0xe0 ||
- (p[1] & 0xc0) == 0x80 ||
- (p[2] & 0xc0) == 0x80) {
+ if (strlen(p) > 2 &&
+ ((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)