aboutsummaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-12 18:07:35 -0700
committerPaul Eggert2011-06-12 18:07:35 -0700
commit34206dd201b905b8f9eec84b4e90ba591b06a79a (patch)
tree3a08862ed4619be5f2675986ec463d3432267cee /src/charset.c
parentc5958d4cf336fdbc30364e7d701d6565acaf4002 (diff)
downloademacs-34206dd201b905b8f9eec84b4e90ba591b06a79a.tar.gz
emacs-34206dd201b905b8f9eec84b4e90ba591b06a79a.zip
Make sure a 64-bit char is never passed to ENCODE_CHAR.
This is for reasons similar to the recent CHAR_STRING fix. * charset.c (Fencode_char): Check that character arg is actually a character. Pass an int to ENCODE_CHAR. * charset.h (ENCODE_CHAR): Verify that the character argument is no wider than 'int', as a compile-time check to prevent future regressions in this area.
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/charset.c b/src/charset.c
index 770e98c99e1..29f98f24089 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1862,14 +1862,15 @@ Optional argument RESTRICTION specifies a way to map CH to a
1862code-point in CCS. Currently not supported and just ignored. */) 1862code-point in CCS. Currently not supported and just ignored. */)
1863 (Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction) 1863 (Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction)
1864{ 1864{
1865 int id; 1865 int c, id;
1866 unsigned code; 1866 unsigned code;
1867 struct charset *charsetp; 1867 struct charset *charsetp;
1868 1868
1869 CHECK_CHARSET_GET_ID (charset, id); 1869 CHECK_CHARSET_GET_ID (charset, id);
1870 CHECK_NATNUM (ch); 1870 CHECK_CHARACTER (ch);
1871 c = XFASTINT (ch);
1871 charsetp = CHARSET_FROM_ID (id); 1872 charsetp = CHARSET_FROM_ID (id);
1872 code = ENCODE_CHAR (charsetp, XINT (ch)); 1873 code = ENCODE_CHAR (charsetp, c);
1873 if (code == CHARSET_INVALID_CODE (charsetp)) 1874 if (code == CHARSET_INVALID_CODE (charsetp))
1874 return Qnil; 1875 return Qnil;
1875 return INTEGER_TO_CONS (code); 1876 return INTEGER_TO_CONS (code);