summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-09-07 03:40:04 (GMT)
committerBenjamin Peterson <benjamin@python.org>2016-09-07 03:40:04 (GMT)
commit89f676f30c63f1805bc3a9e9aff4fc6f0419f959 (patch)
tree2e86aa714c35817b72151ec7426f42231fa98629 /Objects/unicodeobject.c
parent93d1a7051f8c97151a17fe50eb6e5beea91b790f (diff)
downloadcpython-89f676f30c63f1805bc3a9e9aff4fc6f0419f959.zip
cpython-89f676f30c63f1805bc3a9e9aff4fc6f0419f959.tar.gz
cpython-89f676f30c63f1805bc3a9e9aff4fc6f0419f959.tar.bz2
promote some shifts to unsigned, so as not to invoke undefined behavior
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 151ce3c..ca609a9 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2308,7 +2308,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
stream as-is (giving a ZWNBSP character). */
if (bo == 0) {
if (size >= 4) {
- const Py_UCS4 bom = (q[iorder[3]] << 24) | (q[iorder[2]] << 16) |
+ const Py_UCS4 bom = ((unsigned int)q[iorder[3]] << 24) | (q[iorder[2]] << 16) |
(q[iorder[1]] << 8) | q[iorder[0]];
#ifdef BYTEORDER_IS_LITTLE_ENDIAN
if (bom == 0x0000FEFF) {
@@ -2378,7 +2378,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
/* The remaining input chars are ignored if the callback
chooses to skip the input */
}
- ch = (q[iorder[3]] << 24) | (q[iorder[2]] << 16) |
+ ch = ((unsigned int)q[iorder[3]] << 24) | (q[iorder[2]] << 16) |
(q[iorder[1]] << 8) | q[iorder[0]];
if (ch >= 0x110000)