summaryrefslogtreecommitdiff
path: root/src/bidi.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2012-03-23 14:32:23 +0200
committerEli Zaretskii <eliz@gnu.org>2012-03-23 14:32:23 +0200
commite99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (patch)
tree63e7c428a3bed645559e2c1046eb66351e1ea4a3 /src/bidi.c
parent5063c0e1a29078fb72ef5e48e1eeed6a863128ac (diff)
downloademacs-e99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf.tar.gz
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.c8
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,
EMACS_INT endpos
= (string->s || STRINGP (string->lstring)) ? string->schars : ZV;
struct text_pos pos;
+ int len;
/* If we got past the last known position of display string, compute
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,
normal_char:
if (string->s)
{
- int len;
if (!string->unibyte)
{
@@ -1018,8 +1018,6 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
}
else if (STRINGP (string->lstring))
{
- int len;
-
if (!string->unibyte)
{
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,
}
else
{
- ch = FETCH_MULTIBYTE_CHAR (bytepos);
- *ch_len = CHAR_BYTES (ch);
+ ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (bytepos), len);
+ *ch_len = len;
}
*nchars = 1;
}