aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
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/window.c
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/window.c')
-rw-r--r--src/window.c10
1 files changed, 7 insertions, 3 deletions
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