emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115359: Minor integer overflow fixes.


From: Paul Eggert
Subject: [Emacs-diffs] trunk r115359: Minor integer overflow fixes.
Date: Tue, 03 Dec 2013 02:27:20 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115359
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2013-12-02 18:27:10 -0800
message:
  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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/window.c                   window.c-20091113204419-o5vbwnq5f7feedwu-231
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
  src/xfns.c                     xfns.c-20091113204419-o5vbwnq5f7feedwu-274
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-12-02 17:28:17 +0000
+++ b/src/ChangeLog     2013-12-03 02:27:10 +0000
@@ -1,3 +1,12 @@
+2013-12-03  Paul Eggert  <address@hidden>
+
+       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  <address@hidden>
 
        Improve reporting of fatal exception on MS-Windows.

=== modified file 'src/window.c'
--- a/src/window.c      2013-12-01 22:33:13 +0000
+++ b/src/window.c      2013-12-03 02:27:10 +0000
@@ -3646,8 +3646,10 @@
   (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 @@
 
          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);
            }
 

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-12-01 22:33:13 +0000
+++ b/src/xdisp.c       2013-12-03 02:27:10 +0000
@@ -9567,7 +9567,7 @@
   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 @@
   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.  */

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2013-11-30 09:25:31 +0000
+++ b/src/xfns.c        2013-12-03 02:27:10 +0000
@@ -680,7 +680,7 @@
 
   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));
     }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]