aboutsummaryrefslogtreecommitdiffstats
path: root/src/fontset.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-06 01:29:01 -0700
committerPaul Eggert2011-06-06 01:29:01 -0700
commitbe44ca6cd47bff4cb0dfcfd71aa14f10fdab5434 (patch)
tree34110ed6783c1314604f3382e8cd6d0812b939e3 /src/fontset.c
parentd1f3d2afe1057a99b9dec6d1bd5b57bfee81fdff (diff)
downloademacs-be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434.tar.gz
emacs-be44ca6cd47bff4cb0dfcfd71aa14f10fdab5434.zip
Check for overflow when converting integer to cons and back.
* charset.c (Fdefine_charset_internal, Fdecode_char): Use cons_to_unsigned to catch overflow. (Fencode_char): Use INTEGER_TO_CONS. * composite.h (LGLYPH_CODE): Use cons_to_unsigned. (LGLYPH_SET_CODE): Use INTEGER_TO_CONS. * data.c (long_to_cons, cons_to_long): Remove. (cons_to_unsigned, cons_to_signed): New functions. These signal an error for invalid or out-of-range values. * dired.c (Ffile_attributes): Use INTEGER_TO_CONS. * fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER. * font.c (Ffont_variation_glyphs): * fontset.c (Finternal_char_font): Use INTEGER_TO_CONS. * lisp.h: Include <intprops.h>. (INTEGER_TO_CONS, CONS_TO_INTEGER): New macros. (cons_to_signed, cons_to_unsigned): New decls. (long_to_cons, cons_to_long): Remove decls. * undo.c (record_first_change): Use INTEGER_TO_CONS. (Fprimitive_undo): Use CONS_TO_INTEGER. * xfns.c (Fx_window_property): Likewise. * xselect.c: Include <limits.h>. (x_own_selection, selection_data_to_lisp_data): Use INTEGER_TO_CONS. (x_handle_selection_request, x_handle_selection_clear) (x_get_foreign_selection, Fx_disown_selection_internal) (Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER. (lisp_data_to_selection_data): Use cons_to_unsigned. (x_fill_property_data): Use cons_to_signed. Report values out of range.
Diffstat (limited to 'src/fontset.c')
-rw-r--r--src/fontset.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 46637b53b3e..fec3c56b036 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1859,17 +1859,11 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
1859 { 1859 {
1860 unsigned code = face->font->driver->encode_char (face->font, c); 1860 unsigned code = face->font->driver->encode_char (face->font, c);
1861 Lisp_Object font_object; 1861 Lisp_Object font_object;
1862 /* Assignment to EMACS_INT stops GCC whining about limited range
1863 of data type. */
1864 EMACS_INT cod = code;
1865 1862
1866 if (code == FONT_INVALID_CODE) 1863 if (code == FONT_INVALID_CODE)
1867 return Qnil; 1864 return Qnil;
1868 XSETFONT (font_object, face->font); 1865 XSETFONT (font_object, face->font);
1869 if (cod <= MOST_POSITIVE_FIXNUM) 1866 return Fcons (font_object, INTEGER_TO_CONS (code));
1870 return Fcons (font_object, make_number (code));
1871 return Fcons (font_object, Fcons (make_number (code >> 16),
1872 make_number (code & 0xFFFF)));
1873 } 1867 }
1874 return Qnil; 1868 return Qnil;
1875} 1869}