diff options
| author | Paul Eggert | 2020-04-05 01:17:32 -0700 |
|---|---|---|
| committer | Paul Eggert | 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.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) | |||
| 1700 | static void | 1700 | static void |
| 1701 | w32_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | 1701 | w32_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
| 1702 | { | 1702 | { |
| 1703 | int border; | 1703 | int argval = check_integer_range (arg, INT_MIN, INT_MAX); |
| 1704 | 1704 | int border = max (argval, 0); | |
| 1705 | CHECK_TYPE_RANGED_INTEGER (int, arg); | ||
| 1706 | border = max (XFIXNUM (arg), 0); | ||
| 1707 | 1705 | ||
| 1708 | if (border != FRAME_INTERNAL_BORDER_WIDTH (f)) | 1706 | if (border != FRAME_INTERNAL_BORDER_WIDTH (f)) |
| 1709 | { | 1707 | { |
| @@ -9203,8 +9201,8 @@ The coordinates X and Y are interpreted in pixels relative to a position | |||
| 9203 | UINT trail_num = 0; | 9201 | UINT trail_num = 0; |
| 9204 | BOOL ret = false; | 9202 | BOOL ret = false; |
| 9205 | 9203 | ||
| 9206 | CHECK_TYPE_RANGED_INTEGER (int, x); | 9204 | int xval = check_integer_range (x, INT_MIN, INT_MAX); |
| 9207 | CHECK_TYPE_RANGED_INTEGER (int, y); | 9205 | int yval = check_integer_range (y, INT_MIN, INT_MAX); |
| 9208 | 9206 | ||
| 9209 | block_input (); | 9207 | block_input (); |
| 9210 | /* When "mouse trails" are in effect, moving the mouse cursor | 9208 | /* 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 | |||
| 9213 | if (os_subtype == OS_NT | 9211 | if (os_subtype == OS_NT |
| 9214 | && w32_major_version + w32_minor_version >= 6) | 9212 | && w32_major_version + w32_minor_version >= 6) |
| 9215 | ret = SystemParametersInfo (SPI_GETMOUSETRAILS, 0, &trail_num, 0); | 9213 | ret = SystemParametersInfo (SPI_GETMOUSETRAILS, 0, &trail_num, 0); |
| 9216 | SetCursorPos (XFIXNUM (x), XFIXNUM (y)); | 9214 | SetCursorPos (xval, yval); |
| 9217 | if (ret) | 9215 | if (ret) |
| 9218 | SystemParametersInfo (SPI_SETMOUSETRAILS, trail_num, NULL, 0); | 9216 | SystemParametersInfo (SPI_SETMOUSETRAILS, trail_num, NULL, 0); |
| 9219 | unblock_input (); | 9217 | unblock_input (); |