summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2006-10-08 13:56:00 +0000
committerHye-Shik Chang <hyeshik@gmail.com>2006-10-08 13:56:00 +0000
commit2d09be9e488828876228bc435d16ee4b90a2ca08 (patch)
tree46e623a5fbb10d25c3a4edd3f85000808cb35d5f /Modules
parent78754c13ceb37117d94a0dc203ab914c4fd1c8c4 (diff)
downloadcpython-git-2d09be9e488828876228bc435d16ee4b90a2ca08.tar.gz
Backport from trunk r52223:
Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault when encoding non-BMP unicode characters. (Submitted by Ray Chason)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cjkcodecs/_codecs_iso2022.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/Modules/cjkcodecs/_codecs_iso2022.c b/Modules/cjkcodecs/_codecs_iso2022.c
index e785727ac8..f57226343f 100644
--- a/Modules/cjkcodecs/_codecs_iso2022.c
+++ b/Modules/cjkcodecs/_codecs_iso2022.c
@@ -593,9 +593,11 @@ ksx1001_encoder(const ucs4_t *data, int *length)
{
DBCHAR coded;
assert(*length == 1);
- TRYMAP_ENC(cp949, coded, *data)
- if (!(coded & 0x8000))
- return coded;
+ if (*data < 0x10000) {
+ TRYMAP_ENC(cp949, coded, *data)
+ if (!(coded & 0x8000))
+ return coded;
+ }
return MAP_UNMAPPABLE;
}
@@ -629,11 +631,13 @@ jisx0208_encoder(const ucs4_t *data, int *length)
{
DBCHAR coded;
assert(*length == 1);
- if (*data == 0xff3c) /* F/W REVERSE SOLIDUS */
- return 0x2140;
- else TRYMAP_ENC(jisxcommon, coded, *data) {
- if (!(coded & 0x8000))
- return coded;
+ if (*data < 0x10000) {
+ if (*data == 0xff3c) /* F/W REVERSE SOLIDUS */
+ return 0x2140;
+ else TRYMAP_ENC(jisxcommon, coded, *data) {
+ if (!(coded & 0x8000))
+ return coded;
+ }
}
return MAP_UNMAPPABLE;
}
@@ -666,9 +670,11 @@ jisx0212_encoder(const ucs4_t *data, int *length)
{
DBCHAR coded;
assert(*length == 1);
- TRYMAP_ENC(jisxcommon, coded, *data) {
- if (coded & 0x8000)
- return coded & 0x7fff;
+ if (*data < 0x10000) {
+ TRYMAP_ENC(jisxcommon, coded, *data) {
+ if (coded & 0x8000)
+ return coded & 0x7fff;
+ }
}
return MAP_UNMAPPABLE;
}
@@ -971,9 +977,11 @@ gb2312_encoder(const ucs4_t *data, int *length)
{
DBCHAR coded;
assert(*length == 1);
- TRYMAP_ENC(gbcommon, coded, *data) {
- if (!(coded & 0x8000))
- return coded;
+ if (*data < 0x10000) {
+ TRYMAP_ENC(gbcommon, coded, *data) {
+ if (!(coded & 0x8000))
+ return coded;
+ }
}
return MAP_UNMAPPABLE;
}