diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-04-05 01:17:32 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-04-05 01:24:36 -0700 |
commit | bec5cfee7660f6e283efbd30a693a6f8e9ea46b8 (patch) | |
tree | b6b872dfb83579336e848a62f720b629426c0ac0 /src/w32fns.c | |
parent | 9b8dacdb264412b919782920da916e306102262a (diff) | |
download | emacs-bec5cfee7660f6e283efbd30a693a6f8e9ea46b8.tar.gz emacs-bec5cfee7660f6e283efbd30a693a6f8e9ea46b8.tar.bz2 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/w32fns.c')
-rw-r--r-- | src/w32fns.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 2f01fb52e92..9bb4e27b018 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1700,10 +1700,8 @@ w32_clear_under_internal_border (struct frame *f) static void w32_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { - int border; - - CHECK_TYPE_RANGED_INTEGER (int, arg); - border = max (XFIXNUM (arg), 0); + int argval = check_integer_range (arg, INT_MIN, INT_MAX); + int border = max (argval, 0); if (border != FRAME_INTERNAL_BORDER_WIDTH (f)) { @@ -9203,8 +9201,8 @@ The coordinates X and Y are interpreted in pixels relative to a position UINT trail_num = 0; BOOL ret = false; - CHECK_TYPE_RANGED_INTEGER (int, x); - CHECK_TYPE_RANGED_INTEGER (int, y); + int xval = check_integer_range (x, INT_MIN, INT_MAX); + int yval = check_integer_range (y, INT_MIN, INT_MAX); block_input (); /* When "mouse trails" are in effect, moving the mouse cursor @@ -9213,7 +9211,7 @@ The coordinates X and Y are interpreted in pixels relative to a position if (os_subtype == OS_NT && w32_major_version + w32_minor_version >= 6) ret = SystemParametersInfo (SPI_GETMOUSETRAILS, 0, &trail_num, 0); - SetCursorPos (XFIXNUM (x), XFIXNUM (y)); + SetCursorPos (xval, yval); if (ret) SystemParametersInfo (SPI_SETMOUSETRAILS, trail_num, NULL, 0); unblock_input (); |