Commit da92a98c authored by Paul Eggert's avatar Paul Eggert
Browse files

* 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.
parent fda91268
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)):
......
......@@ -204,12 +204,14 @@ bidi_mirror_char (int c)
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment