From 81899c9138d2412a6c9977cb6c47987ca622af27 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 27 May 2012 00:32:46 -0700
Subject: [PATCH] * bidi.c (bidi_mirror_char): Don't possibly truncate the
 integer

before checking whether it's out of range.  Put the check inside
eassert.  See
<http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00485.html>.
---
 src/ChangeLog | 7 +++++++
 src/bidi.c    | 8 ++------
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index a9dae7f68aa..b0b88a86e91 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2012-05-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* bidi.c (bidi_mirror_char): Don't possibly truncate the integer
+	before checking whether it's out of range.  Put the check inside
+	eassert.  See
+	<http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00485.html>.
+
 2012-05-27  Ken Brown  <kbrown@cornell.edu>
 
 	* callproc.c (Fcall_process): Restore a line that was accidentally
diff --git a/src/bidi.c b/src/bidi.c
index efed9dd6cd2..70274560dda 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -204,12 +204,8 @@ bidi_mirror_char (int c)
   val = CHAR_TABLE_REF (bidi_mirror_table, c);
   if (INTEGERP (val))
     {
-      int v = XINT (val);
-
-      if (v < 0 || v > MAX_CHAR)
-	abort ();
-
-      return v;
+      eassert (CHAR_VALID_P (XINT (val)));
+      return XINT (val);
     }
 
   return c;
-- 
2.39.5