From 8fd02eb7d30a7e0e98cc863e0f3cb81a954fe8a9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 12 Jun 2011 18:38:25 -0700 Subject: [PATCH] * chartab.c (Fchar_table_range): Use CHARACTERP to check range. Otherwise, an out-of-range integer could cause undefined behavior on a 64-bit host. --- src/ChangeLog | 4 ++++ src/chartab.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8f98b251234..db01d9f291f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-06-13 Paul Eggert + * chartab.c (Fchar_table_range): Use CHARACTERP to check range. + Otherwise, an out-of-range integer could cause undefined behavior + on a 64-bit host. + * composite.c: Use int, not EMACS_INT, for characters. (fill_gstring_body, composition_compute_stop_pos): Use int, not EMACS_INT, for values that are known to be in character range. diff --git a/src/chartab.c b/src/chartab.c index 2f40ceee6ce..ed5b238646e 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -524,15 +524,15 @@ a cons of character codes (for characters in the range), or a character code. * if (EQ (range, Qnil)) val = XCHAR_TABLE (char_table)->defalt; - else if (INTEGERP (range)) - val = CHAR_TABLE_REF (char_table, XINT (range)); + else if (CHARACTERP (range)) + val = CHAR_TABLE_REF (char_table, XFASTINT (range)); else if (CONSP (range)) { int from, to; CHECK_CHARACTER_CAR (range); CHECK_CHARACTER_CDR (range); - val = char_table_ref_and_range (char_table, XINT (XCAR (range)), + val = char_table_ref_and_range (char_table, XFASTINT (XCAR (range)), &from, &to); /* Not yet implemented. */ } -- 2.39.2