[Python-checkins] bpo-35194: Fix a wrong constant in cp932 codec (GH-10420)

Miss Islington (bot) webhook-mailer at python.org
Fri Nov 9 02:35:09 EST 2018


https://github.com/python/cpython/commit/22234f1375d28803074405497ea61315fb37240d
commit: 22234f1375d28803074405497ea61315fb37240d
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-11-08T23:35:05-08:00
summary:

bpo-35194: Fix a wrong constant in cp932 codec (GH-10420)


This typo doesn't affect the result because wrong bits are discarded
on implicit conversion to unsigned char, but it trips UBSan
with -fsanitize=implicit-integer-truncation.

https://bugs.python.org/issue35194
(cherry picked from commit 7a69cf47a9bbc95f95fd67c982bff121b2a903cb)

Co-authored-by: Alexey Izbyshev <izbyshev at ispras.ru>

files:
M Modules/cjkcodecs/_codecs_jp.c

diff --git a/Modules/cjkcodecs/_codecs_jp.c b/Modules/cjkcodecs/_codecs_jp.c
index 2c7788a64581..3a332953b957 100644
--- a/Modules/cjkcodecs/_codecs_jp.c
+++ b/Modules/cjkcodecs/_codecs_jp.c
@@ -40,7 +40,7 @@ ENCODER(cp932)
             if (c == 0xf8f0)
                 OUTBYTE1(0xa0);
             else
-                OUTBYTE1(c - 0xfef1 + 0xfd);
+                OUTBYTE1(c - 0xf8f1 + 0xfd);
             NEXT(1, 1);
             continue;
         }



More information about the Python-checkins mailing list