diff options
| author | Jason Rumney | 2003-03-16 22:11:04 +0000 |
|---|---|---|
| committer | Jason Rumney | 2003-03-16 22:11:04 +0000 |
| commit | 344630d63cc4d74da633ac0ef5b2ce56d418e9ca (patch) | |
| tree | 4318167d19377de7d2be352ea36c230e4f3de973 /src | |
| parent | f9aaed00d30b67d9a94e1ff86fb0bf2bcaa70985 (diff) | |
| download | emacs-344630d63cc4d74da633ac0ef5b2ce56d418e9ca.tar.gz emacs-344630d63cc4d74da633ac0ef5b2ce56d418e9ca.zip | |
(w32_encode_char): Prevent double-byte chars from crashing Emacs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/w32term.c b/src/w32term.c index fd0e85bb747..c06a45ec55a 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -1134,13 +1134,11 @@ w32_encode_char (c, char2b, font_info, two_byte_p) | |||
| 1134 | int charset = CHAR_CHARSET (c); | 1134 | int charset = CHAR_CHARSET (c); |
| 1135 | int codepage; | 1135 | int codepage; |
| 1136 | int unicode_p = 0; | 1136 | int unicode_p = 0; |
| 1137 | int internal_two_byte_p = 0; | ||
| 1137 | 1138 | ||
| 1138 | XFontStruct *font = font_info->font; | 1139 | XFontStruct *font = font_info->font; |
| 1139 | 1140 | ||
| 1140 | xassert (two_byte_p); | 1141 | internal_two_byte_p = w32_font_is_double_byte (font); |
| 1141 | |||
| 1142 | if (two_byte_p) | ||
| 1143 | *two_byte_p = w32_font_is_double_byte (font); | ||
| 1144 | 1142 | ||
| 1145 | /* FONT_INFO may define a scheme by which to encode byte1 and byte2. | 1143 | /* FONT_INFO may define a scheme by which to encode byte1 and byte2. |
| 1146 | This may be either a program in a special encoder language or a | 1144 | This may be either a program in a special encoder language or a |
| @@ -1167,7 +1165,7 @@ w32_encode_char (c, char2b, font_info, two_byte_p) | |||
| 1167 | 1165 | ||
| 1168 | /* We assume that MSBs are appropriately set/reset by CCL | 1166 | /* We assume that MSBs are appropriately set/reset by CCL |
| 1169 | program. */ | 1167 | program. */ |
| 1170 | if (!*two_byte_p) /* 1-byte font */ | 1168 | if (!internal_two_byte_p) /* 1-byte font */ |
| 1171 | STORE_XCHAR2B (char2b, 0, ccl->reg[1]); | 1169 | STORE_XCHAR2B (char2b, 0, ccl->reg[1]); |
| 1172 | else | 1170 | else |
| 1173 | STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]); | 1171 | STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]); |
| @@ -1214,8 +1212,12 @@ w32_encode_char (c, char2b, font_info, two_byte_p) | |||
| 1214 | MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1); | 1212 | MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1); |
| 1215 | } | 1213 | } |
| 1216 | unicode_p = 1; | 1214 | unicode_p = 1; |
| 1217 | *two_byte_p = 1; | 1215 | internal_two_byte_p = 1; |
| 1218 | } | 1216 | } |
| 1217 | |||
| 1218 | if (two_byte_p) | ||
| 1219 | *two_byte_p = internal_two_byte_p; | ||
| 1220 | |||
| 1219 | if (!font) | 1221 | if (!font) |
| 1220 | return UNKNOWN_FONT; | 1222 | return UNKNOWN_FONT; |
| 1221 | else if (font->bdf && CHARSET_DIMENSION (charset) == 1) | 1223 | else if (font->bdf && CHARSET_DIMENSION (charset) == 1) |