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/process.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/process.c')
| -rw-r--r-- | src/process.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c index e6d18fbaad2..6e5bcf307ab 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1392,14 +1392,12 @@ nil otherwise. */) | |||
| 1392 | CHECK_PROCESS (process); | 1392 | CHECK_PROCESS (process); |
| 1393 | 1393 | ||
| 1394 | /* All known platforms store window sizes as 'unsigned short'. */ | 1394 | /* All known platforms store window sizes as 'unsigned short'. */ |
| 1395 | CHECK_RANGED_INTEGER (height, 0, USHRT_MAX); | 1395 | unsigned short h = check_uinteger_max (height, USHRT_MAX); |
| 1396 | CHECK_RANGED_INTEGER (width, 0, USHRT_MAX); | 1396 | unsigned short w = check_uinteger_max (width, USHRT_MAX); |
| 1397 | 1397 | ||
| 1398 | if (NETCONN_P (process) | 1398 | if (NETCONN_P (process) |
| 1399 | || XPROCESS (process)->infd < 0 | 1399 | || XPROCESS (process)->infd < 0 |
| 1400 | || (set_window_size (XPROCESS (process)->infd, | 1400 | || set_window_size (XPROCESS (process)->infd, h, w) < 0) |
| 1401 | XFIXNUM (height), XFIXNUM (width)) | ||
| 1402 | < 0)) | ||
| 1403 | return Qnil; | 1401 | return Qnil; |
| 1404 | else | 1402 | else |
| 1405 | return Qt; | 1403 | return Qt; |
| @@ -7075,10 +7073,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) | |||
| 7075 | } | 7073 | } |
| 7076 | 7074 | ||
| 7077 | if (FIXNUMP (sigcode)) | 7075 | if (FIXNUMP (sigcode)) |
| 7078 | { | 7076 | signo = check_integer_range (sigcode, INT_MIN, INT_MAX); |
| 7079 | CHECK_TYPE_RANGED_INTEGER (int, sigcode); | ||
| 7080 | signo = XFIXNUM (sigcode); | ||
| 7081 | } | ||
| 7082 | else | 7077 | else |
| 7083 | { | 7078 | { |
| 7084 | char *name; | 7079 | char *name; |