Commit 25636e13 authored by Paul Eggert's avatar Paul Eggert

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.
parent 9139632a
2013-12-03 Paul Eggert <eggert@cs.ucla.edu>
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.
2013-12-02 Eli Zaretskii <eliz@gnu.org>
Improve reporting of fatal exception on MS-Windows.
......
......@@ -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);
}
......
......@@ -9567,7 +9567,7 @@ include the height of any of these lines in the return value. */)
if (!NILP (y_limit))
{
CHECK_NUMBER (y_limit);
max_y = XINT (y_limit);
max_y = min (XINT (y_limit), INT_MAX);
}
itdata = bidi_shelve_cache ();
......@@ -9580,7 +9580,7 @@ include the height of any of these lines in the return value. */)
else
{
CHECK_NUMBER (x_limit);
it.last_visible_x = XINT (x_limit);
it.last_visible_x = min (XINT (x_limit), INFINITY);
/* Actually, we never want move_it_to stop at to_x. But to make
sure that move_it_in_display_line_to always moves far enough,
we set it to INT_MAX and specify MOVE_TO_X. */
......
......@@ -680,7 +680,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
if (!NILP (Vx_window_horizontal_drag_shape))
{
CHECK_NUMBER (Vx_window_horizontal_drag_shape);
CHECK_TYPE_RANGED_INTEGER (unsigned, Vx_window_horizontal_drag_shape);
horizontal_drag_cursor
= XCreateFontCursor (dpy, XINT (Vx_window_horizontal_drag_shape));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment