+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.
(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
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);
}
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 ();
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. */
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));
}