aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu.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/menu.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/menu.c')
-rw-r--r--src/menu.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/menu.c b/src/menu.c
index 28bfcae05d6..6b8b5dd1210 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1253,18 +1253,16 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
1253 but I don't want to make one now. */ 1253 but I don't want to make one now. */
1254 CHECK_WINDOW (window); 1254 CHECK_WINDOW (window);
1255 1255
1256 CHECK_RANGED_INTEGER (x, 1256 xpos += check_integer_range (x,
1257 (xpos < INT_MIN - MOST_NEGATIVE_FIXNUM 1257 (xpos < INT_MIN - MOST_NEGATIVE_FIXNUM
1258 ? (EMACS_INT) INT_MIN - xpos 1258 ? (EMACS_INT) INT_MIN - xpos
1259 : MOST_NEGATIVE_FIXNUM), 1259 : MOST_NEGATIVE_FIXNUM),
1260 INT_MAX - xpos); 1260 INT_MAX - xpos);
1261 CHECK_RANGED_INTEGER (y, 1261 ypos += check_integer_range (y,
1262 (ypos < INT_MIN - MOST_NEGATIVE_FIXNUM 1262 (ypos < INT_MIN - MOST_NEGATIVE_FIXNUM
1263 ? (EMACS_INT) INT_MIN - ypos 1263 ? (EMACS_INT) INT_MIN - ypos
1264 : MOST_NEGATIVE_FIXNUM), 1264 : MOST_NEGATIVE_FIXNUM),
1265 INT_MAX - ypos); 1265 INT_MAX - ypos);
1266 xpos += XFIXNUM (x);
1267 ypos += XFIXNUM (y);
1268 1266
1269 XSETFRAME (Vmenu_updating_frame, f); 1267 XSETFRAME (Vmenu_updating_frame, f);
1270 } 1268 }