diff options
| author | Eli Zaretskii | 2012-03-23 14:32:23 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-03-23 14:32:23 +0200 |
| commit | e99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (patch) | |
| tree | 63e7c428a3bed645559e2c1046eb66351e1ea4a3 /src/bidi.c | |
| parent | 5063c0e1a29078fb72ef5e48e1eeed6a863128ac (diff) | |
| download | emacs-e99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf.tar.gz emacs-e99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf.zip | |
Fix bug #11073 with bidi-related crashes displaying some byte sequences.
src/bidi.c (bidi_fetch_char): Use STRING_CHAR_AND_LENGTH instead of
FETCH_MULTIBYTE_CHAR followed by CHAR_BYTES. Prevents crashes
when fetching a multibyte character consumes more bytes than
CHAR_BYTES returns, due to unification of CJK characters in
string_char.
Diffstat (limited to 'src/bidi.c')
| -rw-r--r-- | src/bidi.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/bidi.c b/src/bidi.c index 107c817abba..b3479b17b16 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -932,6 +932,7 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 932 | EMACS_INT endpos | 932 | EMACS_INT endpos |
| 933 | = (string->s || STRINGP (string->lstring)) ? string->schars : ZV; | 933 | = (string->s || STRINGP (string->lstring)) ? string->schars : ZV; |
| 934 | struct text_pos pos; | 934 | struct text_pos pos; |
| 935 | int len; | ||
| 935 | 936 | ||
| 936 | /* If we got past the last known position of display string, compute | 937 | /* If we got past the last known position of display string, compute |
| 937 | the position of the next one. That position could be at CHARPOS. */ | 938 | the position of the next one. That position could be at CHARPOS. */ |
| @@ -1003,7 +1004,6 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 1003 | normal_char: | 1004 | normal_char: |
| 1004 | if (string->s) | 1005 | if (string->s) |
| 1005 | { | 1006 | { |
| 1006 | int len; | ||
| 1007 | 1007 | ||
| 1008 | if (!string->unibyte) | 1008 | if (!string->unibyte) |
| 1009 | { | 1009 | { |
| @@ -1018,8 +1018,6 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 1018 | } | 1018 | } |
| 1019 | else if (STRINGP (string->lstring)) | 1019 | else if (STRINGP (string->lstring)) |
| 1020 | { | 1020 | { |
| 1021 | int len; | ||
| 1022 | |||
| 1023 | if (!string->unibyte) | 1021 | if (!string->unibyte) |
| 1024 | { | 1022 | { |
| 1025 | ch = STRING_CHAR_AND_LENGTH (SDATA (string->lstring) + bytepos, | 1023 | ch = STRING_CHAR_AND_LENGTH (SDATA (string->lstring) + bytepos, |
| @@ -1034,8 +1032,8 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 1034 | } | 1032 | } |
| 1035 | else | 1033 | else |
| 1036 | { | 1034 | { |
| 1037 | ch = FETCH_MULTIBYTE_CHAR (bytepos); | 1035 | ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (bytepos), len); |
| 1038 | *ch_len = CHAR_BYTES (ch); | 1036 | *ch_len = len; |
| 1039 | } | 1037 | } |
| 1040 | *nchars = 1; | 1038 | *nchars = 1; |
| 1041 | } | 1039 | } |