From 237171731157095f5cc46b0f6f6205e3b4ba9f00 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 8 Feb 2015 18:14:14 -0800 Subject: [PATCH] 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. --- src/ChangeLog | 4 ++++ src/bidi.c | 5 +++++ 2 files changed, 9 insertions(+) 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 -- 2.39.2