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/xwidget.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/xwidget.c')
| -rw-r--r-- | src/xwidget.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/xwidget.c b/src/xwidget.c index ea8987f5b3b..0347f1e6483 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -750,11 +750,9 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, | |||
| 750 | (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) | 750 | (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) |
| 751 | { | 751 | { |
| 752 | CHECK_XWIDGET (xwidget); | 752 | CHECK_XWIDGET (xwidget); |
| 753 | CHECK_RANGED_INTEGER (new_width, 0, INT_MAX); | 753 | int w = check_integer_range (new_width, 0, INT_MAX); |
| 754 | CHECK_RANGED_INTEGER (new_height, 0, INT_MAX); | 754 | int h = check_integer_range (new_height, 0, INT_MAX); |
| 755 | struct xwidget *xw = XXWIDGET (xwidget); | 755 | struct xwidget *xw = XXWIDGET (xwidget); |
| 756 | int w = XFIXNAT (new_width); | ||
| 757 | int h = XFIXNAT (new_height); | ||
| 758 | 756 | ||
| 759 | xw->width = w; | 757 | xw->width = w; |
| 760 | xw->height = h; | 758 | xw->height = h; |