aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-12-02 18:27:10 -0800
committerPaul Eggert2013-12-02 18:27:10 -0800
commit25636e136267379f6b32b8dff712f72438cbec35 (patch)
treee72b043bffce81b3f87bce01de184fe40666e0d9 /src
parent9139632a34c396ccd1677e86f3e4e870c025b2e3 (diff)
downloademacs-25636e136267379f6b32b8dff712f72438cbec35.tar.gz
emacs-25636e136267379f6b32b8dff712f72438cbec35.zip
Minor integer overflow fixes.
* window.c (Fset_window_new_pixel, grow_mini_window): * xdisp.c (Fwindow_text_pixel_size): Avoid undefined behavior on signed integer overflow. * xfns.c (x_set_mouse_color): Check that drag shape fits in 'unsigned', since that's what X wants.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/window.c10
-rw-r--r--src/xdisp.c4
-rw-r--r--src/xfns.c2
4 files changed, 19 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a5c6668c551..d26a3798b09 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12013-12-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 Minor integer overflow fixes.
4 * window.c (Fset_window_new_pixel, grow_mini_window):
5 * xdisp.c (Fwindow_text_pixel_size):
6 Avoid undefined behavior on signed integer overflow.
7 * xfns.c (x_set_mouse_color):
8 Check that drag shape fits in 'unsigned', since that's what X wants.
9
12013-12-02 Eli Zaretskii <eliz@gnu.org> 102013-12-02 Eli Zaretskii <eliz@gnu.org>
2 11
3 Improve reporting of fatal exception on MS-Windows. 12 Improve reporting of fatal exception on MS-Windows.
diff --git a/src/window.c b/src/window.c
index a28449ba1db..e2770410bce 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3646,8 +3646,10 @@ Note: This function does not operate on any child windows of WINDOW. */)
3646 (Lisp_Object window, Lisp_Object size, Lisp_Object add) 3646 (Lisp_Object window, Lisp_Object size, Lisp_Object add)
3647{ 3647{
3648 struct window *w = decode_valid_window (window); 3648 struct window *w = decode_valid_window (window);
3649 EMACS_INT size_max = (min (INT_MAX, MOST_POSITIVE_FIXNUM)
3650 - (NILP (add) ? 0 : XINT (w->new_pixel)));
3649 3651
3650 CHECK_NUMBER (size); 3652 CHECK_RANGED_INTEGER (size, 0, size_max);
3651 if (NILP (add)) 3653 if (NILP (add))
3652 wset_new_pixel (w, size); 3654 wset_new_pixel (w, size);
3653 else 3655 else
@@ -4556,12 +4558,14 @@ grow_mini_window (struct window *w, int delta, bool pixelwise)
4556 4558
4557 if (pixelwise) 4559 if (pixelwise)
4558 { 4560 {
4559 pixel_height = -XINT (height); 4561 pixel_height = min (-XINT (height), INT_MAX - w->pixel_height);
4560 line_height = pixel_height / FRAME_LINE_HEIGHT (f); 4562 line_height = pixel_height / FRAME_LINE_HEIGHT (f);
4561 } 4563 }
4562 else 4564 else
4563 { 4565 {
4564 line_height = -XINT (height); 4566 line_height = min (-XINT (height),
4567 ((INT_MAX - w->pixel_height)
4568 / FRAME_LINE_HEIGHT (f)));
4565 pixel_height = line_height * FRAME_LINE_HEIGHT (f); 4569 pixel_height = line_height * FRAME_LINE_HEIGHT (f);
4566 } 4570 }
4567 4571
diff --git a/src/xdisp.c b/src/xdisp.c
index b52c89a7556..d1c8cd3cf28 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9567,7 +9567,7 @@ include the height of any of these lines in the return value. */)
9567 if (!NILP (y_limit)) 9567 if (!NILP (y_limit))
9568 { 9568 {
9569 CHECK_NUMBER (y_limit); 9569 CHECK_NUMBER (y_limit);
9570 max_y = XINT (y_limit); 9570 max_y = min (XINT (y_limit), INT_MAX);
9571 } 9571 }
9572 9572
9573 itdata = bidi_shelve_cache (); 9573 itdata = bidi_shelve_cache ();
@@ -9580,7 +9580,7 @@ include the height of any of these lines in the return value. */)
9580 else 9580 else
9581 { 9581 {
9582 CHECK_NUMBER (x_limit); 9582 CHECK_NUMBER (x_limit);
9583 it.last_visible_x = XINT (x_limit); 9583 it.last_visible_x = min (XINT (x_limit), INFINITY);
9584 /* Actually, we never want move_it_to stop at to_x. But to make 9584 /* Actually, we never want move_it_to stop at to_x. But to make
9585 sure that move_it_in_display_line_to always moves far enough, 9585 sure that move_it_in_display_line_to always moves far enough,
9586 we set it to INT_MAX and specify MOVE_TO_X. */ 9586 we set it to INT_MAX and specify MOVE_TO_X. */
diff --git a/src/xfns.c b/src/xfns.c
index bd4a6a62db6..2830a79972c 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -680,7 +680,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
680 680
681 if (!NILP (Vx_window_horizontal_drag_shape)) 681 if (!NILP (Vx_window_horizontal_drag_shape))
682 { 682 {
683 CHECK_NUMBER (Vx_window_horizontal_drag_shape); 683 CHECK_TYPE_RANGED_INTEGER (unsigned, Vx_window_horizontal_drag_shape);
684 horizontal_drag_cursor 684 horizontal_drag_cursor
685 = XCreateFontCursor (dpy, XINT (Vx_window_horizontal_drag_shape)); 685 = XCreateFontCursor (dpy, XINT (Vx_window_horizontal_drag_shape));
686 } 686 }