aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2020-04-05 01:17:32 -0700
committerPaul Eggert2020-04-05 01:24:36 -0700
commitbec5cfee7660f6e283efbd30a693a6f8e9ea46b8 (patch)
treeb6b872dfb83579336e848a62f720b629426c0ac0 /src/coding.c
parent9b8dacdb264412b919782920da916e306102262a (diff)
downloademacs-bec5cfee7660f6e283efbd30a693a6f8e9ea46b8.tar.gz
emacs-bec5cfee7660f6e283efbd30a693a6f8e9ea46b8.zip
Improve integer range checking
* src/bignum.c (check_integer_range, check_uinteger_max) (check_int_nonnegative): New functions. * src/frame.c (check_frame_pixels): New function. (Fset_frame_height, Fset_frame_width, Fset_frame_size): Use it. * src/lisp.h (CHECK_RANGED_INTEGER, CHECK_TYPE_RANGED_INTEGER): Remove these macros. Unless otherwise specified, all callers replaced by calls to check_integer_range, check_uinteger_range, check_int_nonnegative. * src/frame.c (gui_set_right_divider_width) (gui_set_bottom_divider_width): * src/nsfns.m (ns_set_internal_border_width): * src/xfns.c (x_set_internal_border_width): Using check_int_nonnegative means these functions no longer incorrectly reject negative bignums; they treat them as 0, just like negative fixnums.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c
index 0bea2a0c2bc..f0fc37dbdfa 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -11061,10 +11061,8 @@ usage: (define-coding-system-internal ...) */)
11061 else 11061 else
11062 { 11062 {
11063 CHECK_CONS (val); 11063 CHECK_CONS (val);
11064 CHECK_RANGED_INTEGER (XCAR (val), 0, 255); 11064 from = check_integer_range (XCAR (val), 0, 255);
11065 from = XFIXNUM (XCAR (val)); 11065 to = check_integer_range (XCDR (val), from, 255);
11066 CHECK_RANGED_INTEGER (XCDR (val), from, 255);
11067 to = XFIXNUM (XCDR (val));
11068 } 11066 }
11069 for (int i = from; i <= to; i++) 11067 for (int i = from; i <= to; i++)
11070 SSET (valids, i, 1); 11068 SSET (valids, i, 1);
@@ -11149,7 +11147,7 @@ usage: (define-coding-system-internal ...) */)
11149 val = XCAR (tail); 11147 val = XCAR (tail);
11150 CHECK_CONS (val); 11148 CHECK_CONS (val);
11151 CHECK_CHARSET_GET_ID (XCAR (val), id); 11149 CHECK_CHARSET_GET_ID (XCAR (val), id);
11152 CHECK_RANGED_INTEGER (XCDR (val), 0, 3); 11150 check_integer_range (XCDR (val), 0, 3);
11153 XSETCAR (val, make_fixnum (id)); 11151 XSETCAR (val, make_fixnum (id));
11154 } 11152 }
11155 11153