+2012-05-28 Paul Eggert <eggert@cs.ucla.edu>
+
+ * 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 <lekktu@gmail.com>
* makefile.w32-in ($(BLD)/w32inevt.$(O), $(BLD)/w32console.$(O)):
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)