aboutsummaryrefslogtreecommitdiffstats
path: root/src/dosfns.c
diff options
context:
space:
mode:
authorPaul Eggert2019-06-27 12:31:27 -0700
committerPaul Eggert2019-06-27 12:35:08 -0700
commit4893a09c005cac81c05cd3db05c87225be6a7b42 (patch)
tree1e1e193f61c97067076a1b2f0940c79d5e92ed33 /src/dosfns.c
parent3502d4c1b587057c2f5907997f74ae0a2e0d2a7d (diff)
downloademacs-4893a09c005cac81c05cd3db05c87225be6a7b42.tar.gz
emacs-4893a09c005cac81c05cd3db05c87225be6a7b42.zip
Clean up use of XFIXNUM etc.
A few bits of the code were relying on the fact that XFIXNUM, XFIXNAT, and XUFIXNUM do something even with arguments that are not fixnums/fixnats. Separate these rare uses out into XFIXNUM_RAW and XUFIXNUM_RAW. Problem and original patch reported by Pip Cet (Bug#36370). * src/ccl.c (Fccl_execute_on_string): * src/fileio.c (Finsert_file_contents, a_write) (Fdo_auto_save): * src/process.c (conv_lisp_to_sockaddr): * src/textprop.c (Fnext_single_char_property_change) (Fprevious_single_char_property_change) (Fnext_property_change, Fnext_single_property_change) (Fprevious_property_change) (Fprevious_single_property_change): Don’t assume fixnums are nonnegative. * src/ccl.c (Fccl_execute_on_string): Fix range-checking bug if AREF (status, i) is out of int range. * src/data.c (arith_driver): Use XFIXNUM_RAW as we want efficient garbage if the value is not a fixnum. * src/dosfns.c (Fint86, Fdos_memput): Check that args are nonnegative. * src/image.c (lookup_image): Check that args are in range. * src/lisp.h (lisp_h_XHASH): Use XUFIXNUM_RAW, since this is for hashing. (lisp_h_XFIXNAT, XFIXNAT) [USE_LSB_TAG]: Remove macros. (lisp_h_XFIXNUM_RAW, XFIXNUM_RAW) [USE_LSB_TAG]: New macros, with the semantics of the old macros without _RAW. (XFIXNUM_RAW, XUFIXNUM_RAW): New inline functions, with the semantics of the old functions without _RAW. (FIXNUMP): Move definition up to avoid forward use. (XFIXNUM, XFIXNAT, XUFIXNUM): Use eassume to add a runtime check (when debugging) that the argument has the proper form. (XFIXNUM, XFIXNAT): Now inline functions only, since they refer to their arguments more than once now that they use eassume. * src/textprop.c (Fprevious_single_char_property_change): Avoid fixnum overflow with invalid input. (set_text_properties): Fix unlikely failure to validate arguments, by using EQ instead of XFIXNAT. * src/w32term.c (w32_draw_glyph_string): * src/xterm.c (x_draw_glyph_string): Treat negative minimums as 0 rather than as garbage patterns.
Diffstat (limited to 'src/dosfns.c')
-rw-r--r--src/dosfns.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dosfns.c b/src/dosfns.c
index 47c545007ad..fb5bcc9ad3f 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -72,7 +72,7 @@ REGISTERS should be a vector produced by `make-register' and
72 if (no < 0 || no > 0xff || ASIZE (registers) != 8) 72 if (no < 0 || no > 0xff || ASIZE (registers) != 8)
73 return Qnil; 73 return Qnil;
74 for (i = 0; i < 8; i++) 74 for (i = 0; i < 8; i++)
75 CHECK_FIXNUM (AREF (registers, i)); 75 CHECK_FIXNAT (AREF (registers, i));
76 76
77 inregs.x.ax = (unsigned long) XFIXNAT (AREF (registers, 0)); 77 inregs.x.ax = (unsigned long) XFIXNAT (AREF (registers, 0));
78 inregs.x.bx = (unsigned long) XFIXNAT (AREF (registers, 1)); 78 inregs.x.bx = (unsigned long) XFIXNAT (AREF (registers, 1));
@@ -139,7 +139,7 @@ DEFUN ("msdos-memput", Fdos_memput, Sdos_memput, 2, 2, 0,
139 139
140 for (i = 0; i < len; i++) 140 for (i = 0; i < len; i++)
141 { 141 {
142 CHECK_FIXNUM (AREF (vector, i)); 142 CHECK_FIXNAT (AREF (vector, i));
143 buf[i] = (unsigned char) XFIXNAT (AREF (vector, i)) & 0xFF; 143 buf[i] = (unsigned char) XFIXNAT (AREF (vector, i)) & 0xFF;
144 } 144 }
145 145