aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-03-23 14:32:23 +0200
committerEli Zaretskii2012-03-23 14:32:23 +0200
commite99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (patch)
tree63e7c428a3bed645559e2c1046eb66351e1ea4a3 /src
parent5063c0e1a29078fb72ef5e48e1eeed6a863128ac (diff)
downloademacs-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')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/bidi.c8
2 files changed, 11 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 40186c65496..028b8325aae 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-03-23 Eli Zaretskii <eliz@gnu.org>
2
3 * bidi.c (bidi_fetch_char): Use STRING_CHAR_AND_LENGTH instead of
4 FETCH_MULTIBYTE_CHAR followed by CHAR_BYTES. Prevents crashes
5 when fetching a multibyte character consumes more bytes than
6 CHAR_BYTES returns, due to unification of CJK characters in
7 string_char. (Bug#11073)
8
12012-03-23 Troels Nielsen <bn.troels@gmail.com> (tiny change) 92012-03-23 Troels Nielsen <bn.troels@gmail.com> (tiny change)
2 10
3 * process.c (wait_reading_process_output): Handle pty disconnect 11 * process.c (wait_reading_process_output): Handle pty disconnect
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 }