mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-02 11:50:48 -08:00
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.
This commit is contained in:
parent
9b8dacdb26
commit
bec5cfee76
16 changed files with 158 additions and 205 deletions
|
|
@ -1392,14 +1392,12 @@ nil otherwise. */)
|
|||
CHECK_PROCESS (process);
|
||||
|
||||
/* All known platforms store window sizes as 'unsigned short'. */
|
||||
CHECK_RANGED_INTEGER (height, 0, USHRT_MAX);
|
||||
CHECK_RANGED_INTEGER (width, 0, USHRT_MAX);
|
||||
unsigned short h = check_uinteger_max (height, USHRT_MAX);
|
||||
unsigned short w = check_uinteger_max (width, USHRT_MAX);
|
||||
|
||||
if (NETCONN_P (process)
|
||||
|| XPROCESS (process)->infd < 0
|
||||
|| (set_window_size (XPROCESS (process)->infd,
|
||||
XFIXNUM (height), XFIXNUM (width))
|
||||
< 0))
|
||||
|| set_window_size (XPROCESS (process)->infd, h, w) < 0)
|
||||
return Qnil;
|
||||
else
|
||||
return Qt;
|
||||
|
|
@ -7075,10 +7073,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
|
|||
}
|
||||
|
||||
if (FIXNUMP (sigcode))
|
||||
{
|
||||
CHECK_TYPE_RANGED_INTEGER (int, sigcode);
|
||||
signo = XFIXNUM (sigcode);
|
||||
}
|
||||
signo = check_integer_range (sigcode, INT_MIN, INT_MAX);
|
||||
else
|
||||
{
|
||||
char *name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue