]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35194: Fix a wrong constant in cp932 codec (GH-10420)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 9 Nov 2018 07:33:10 +0000 (23:33 -0800)
committerGitHub <noreply@github.com>
Fri, 9 Nov 2018 07:33:10 +0000 (23:33 -0800)
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@ispras.ru>
Modules/cjkcodecs/_codecs_jp.c

index 2c7788a645813c279ef4a6f380c187847ce7b6dd..3a332953b957cbdd968d8d293a6ed4a1afa47905 100644 (file)
@@ -40,7 +40,7 @@ ENCODER(cp932)
             if (c == 0xf8f0)
                 OUTBYTE1(0xa0);
             else
-                OUTBYTE1(c - 0xfef1 + 0xfd);
+                OUTBYTE1(c - 0xf8f1 + 0xfd);
             NEXT(1, 1);
             continue;
         }