summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-12-02 18:27:10 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2013-12-02 18:27:10 -0800
commit25636e136267379f6b32b8dff712f72438cbec35 (patch)
treee72b043bffce81b3f87bce01de184fe40666e0d9 /src/window.c
parent9139632a34c396ccd1677e86f3e4e870c025b2e3 (diff)
downloademacs-25636e136267379f6b32b8dff712f72438cbec35.tar.gz
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. */)
(Lisp_Object window, Lisp_Object size, Lisp_Object add)
{
struct window *w = decode_valid_window (window);
+ EMACS_INT size_max = (min (INT_MAX, MOST_POSITIVE_FIXNUM)
+ - (NILP (add) ? 0 : XINT (w->new_pixel)));
- CHECK_NUMBER (size);
+ CHECK_RANGED_INTEGER (size, 0, size_max);
if (NILP (add))
wset_new_pixel (w, size);
else
@@ -4556,12 +4558,14 @@ grow_mini_window (struct window *w, int delta, bool pixelwise)
if (pixelwise)
{
- pixel_height = -XINT (height);
+ pixel_height = min (-XINT (height), INT_MAX - w->pixel_height);
line_height = pixel_height / FRAME_LINE_HEIGHT (f);
}
else
{
- line_height = -XINT (height);
+ line_height = min (-XINT (height),
+ ((INT_MAX - w->pixel_height)
+ / FRAME_LINE_HEIGHT (f)));
pixel_height = line_height * FRAME_LINE_HEIGHT (f);
}