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)
commit33d2a492d0c0c29f526fae1e0f164fe14864cc2e (patch)
tree0ecbf1c72cbe0d7bca225da9e80ff41cf51721f9 /Objects/unicodeobject.c
parent4a757609d131a29ef52eddcae108b7052e13d31b (diff)
downloadcpython-33d2a492d0c0c29f526fae1e0f164fe14864cc2e.zip
cpython-33d2a492d0c0c29f526fae1e0f164fe14864cc2e.tar.gz
cpython-33d2a492d0c0c29f526fae1e0f164fe14864cc2e.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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 1fcc83e..af04564 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4944,7 +4944,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
mark is skipped, in all other modes, it is copied to the output
stream as-is (giving a ZWNBSP character). */
if (bo == 0 && size >= 4) {
- Py_UCS4 bom = (q[3] << 24) | (q[2] << 16) | (q[1] << 8) | q[0];
+ Py_UCS4 bom = ((unsigned int)q[3] << 24) | (q[2] << 16) | (q[1] << 8) | q[0];
if (bom == 0x0000FEFF) {
bo = -1;
q += 4;
@@ -4986,7 +4986,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
Py_ssize_t pos = writer.pos;
if (le) {
do {
- ch = (q[3] << 24) | (q[2] << 16) | (q[1] << 8) | q[0];
+ ch = ((unsigned int)q[3] << 24) | (q[2] << 16) | (q[1] << 8) | q[0];
if (ch > maxch)
break;
if (kind != PyUnicode_1BYTE_KIND &&
@@ -4998,7 +4998,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
}
else {
do {
- ch = (q[0] << 24) | (q[1] << 16) | (q[2] << 8) | q[3];
+ ch = ((unsigned int)q[0] << 24) | (q[1] << 16) | (q[2] << 8) | q[3];
if (ch > maxch)
break;
if (kind != PyUnicode_1BYTE_KIND &&