emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 2371717: Fix bidi_explicit_dir_char undefined behav


From: Paul Eggert
Subject: [Emacs-diffs] master 2371717: Fix bidi_explicit_dir_char undefined behavior
Date: Mon, 09 Feb 2015 02:14:46 +0000

branch: master
commit 237171731157095f5cc46b0f6f6205e3b4ba9f00
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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(+), 0 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 017b8f1..3b2c9a6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
 2015-02-09  Paul Eggert  <address@hidden>
 
+       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 cbc1820..e5e08c6 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]