From: Paul Eggert Date: Mon, 9 Feb 2015 02:14:14 +0000 (-0800) Subject: Fix bidi_explicit_dir_char undefined behavior X-Git-Tag: emacs-25.0.90~2008^2~55 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=237171731157095f5cc46b0f6f6205e3b4ba9f00;p=emacs.git Fix bidi_explicit_dir_char undefined behavior * bidi.c (bidi_explicit_dir_char): Avoid subscript error when argument is BIDI_EOB. This can happen in bidi_level_of_next_char. --- diff --git a/src/ChangeLog b/src/ChangeLog index 017b8f15e3b..3b2c9a6777f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2015-02-09 Paul Eggert + Fix bidi_explicit_dir_char undefined behavior + * bidi.c (bidi_explicit_dir_char): Avoid subscript error when + argument is BIDI_EOB. This can happen in bidi_level_of_next_char. + Better distinguish infinite from invalid times * editfns.c (check_time_validity): New function. (decode_time_components): Return int, not bool. diff --git a/src/bidi.c b/src/bidi.c index cbc1820c2a5..e5e08c6a252 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1799,6 +1799,11 @@ bidi_explicit_dir_char (int ch) if (!bidi_initialized) emacs_abort (); + if (ch < 0) + { + eassert (ch == BIDI_EOB); + return false; + } ch_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); return (ch_type == LRE || ch_type == LRO || ch_type == RLE || ch_type == RLO