emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r108404: * bidi.c (bidi_mirror_char):


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108404: * bidi.c (bidi_mirror_char): Put eassert before conversion to int.
Date: Mon, 28 May 2012 00:13:45 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108404
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2012-05-28 00:13:45 -0700
message:
  * bidi.c (bidi_mirror_char): Put eassert before conversion to int.
  
  This avoids undefined behavior that might cause the eassert
  to not catch an out-of-range value.
modified:
  src/ChangeLog
  src/bidi.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-05-28 01:58:42 +0000
+++ b/src/ChangeLog     2012-05-28 07:13:45 +0000
@@ -1,3 +1,9 @@
+2012-05-28  Paul Eggert  <address@hidden>
+
+       * bidi.c (bidi_mirror_char): Put eassert before conversion to int.
+       This avoids undefined behavior that might cause the eassert
+       to not catch an out-of-range value.
+
 2012-05-28  Juanma Barranquero  <address@hidden>
 
        * makefile.w32-in ($(BLD)/w32inevt.$(O), $(BLD)/w32console.$(O)):

=== modified file 'src/bidi.c'
--- a/src/bidi.c        2012-05-27 12:27:07 +0000
+++ b/src/bidi.c        2012-05-28 07:13:45 +0000
@@ -204,12 +204,14 @@
   val = CHAR_TABLE_REF (bidi_mirror_table, c);
   if (INTEGERP (val))
     {
-      int v = XINT (val);
+      int v;
 
-      /* In a build with extra checks, make sure the value does not
-        overflow a 32-bit int.  */
+      /* When debugging, check before assigning to V, so that the check
+        isn't broken by undefined behavior due to int overflow.  */
       eassert (CHAR_VALID_P (XINT (val)));
 
+      v = XINT (val);
+
       /* Minimal test we must do in optimized builds, to prevent weird
         crashes further down the road.  */
       if (v < 0 || v > MAX_CHAR)


reply via email to

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