emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r117515: Fix bug #18528 with crashes at startup d


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 r117515: Fix bug #18528 with crashes at startup during frameset restoration.
Date: Wed, 24 Sep 2014 07:32:52 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117515
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/18528
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Wed 2014-09-24 10:31:11 +0300
message:
  Fix bug #18528 with crashes at startup during frameset restoration.
  
   src/w32term.c (w32_read_socket): Don't use frame dimensions for
   resizing if GetClientRect returned an empty (0, 0, 0, 0)
   rectangle.  Check the return value of GetClientRect, and don't use
   the results if it didn't succeed.
   src/dispnew.c (change_frame_size_1): Recompute the frame dimensions
   in columns and lines after correcting the pixel dimensions in
   check_frame_size.
   (adjust_decode_mode_spec_buffer): Add assertion to avoid passing
   negative values to xrealloc.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispnew.c                  dispnew.c-20091113204419-o5vbwnq5f7feedwu-258
  src/w32term.c                  w32term.c-20091113204419-o5vbwnq5f7feedwu-950
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-09-22 05:34:05 +0000
+++ b/src/ChangeLog     2014-09-24 07:31:11 +0000
@@ -1,3 +1,16 @@
+2014-09-24  Eli Zaretskii  <address@hidden>
+
+       * w32term.c (w32_read_socket): Don't use frame dimensions for
+       resizing if GetClientRect returned an empty (0, 0, 0, 0)
+       rectangle.  Check the return value of GetClientRect, and don't use
+       the results if it didn't succeed.
+
+       * dispnew.c (change_frame_size_1): Recompute the frame dimensions
+       in columns and lines after correcting the pixel dimensions in
+       check_frame_size.
+       (adjust_decode_mode_spec_buffer): Add assertion to avoid passing
+       negative values to xrealloc.  (Bug#18528)
+
 2014-09-22  Dmitry Antipov  <address@hidden>
 
        On OSX, do not free font-specific data more than once (Bug#18501).

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2014-09-07 17:16:36 +0000
+++ b/src/dispnew.c     2014-09-24 07:31:11 +0000
@@ -2138,8 +2138,11 @@
 static void
 adjust_decode_mode_spec_buffer (struct frame *f)
 {
+  ssize_t frame_message_buf_size = FRAME_MESSAGE_BUF_SIZE (f);
+
+  eassert (frame_message_buf_size >= 0);
   f->decode_mode_spec_buffer = xrealloc (f->decode_mode_spec_buffer,
-                                        FRAME_MESSAGE_BUF_SIZE (f) + 1);
+                                        frame_message_buf_size + 1);
 }
 
 
@@ -5539,10 +5542,6 @@
     {
       new_text_width = (new_width == 0) ? FRAME_TEXT_WIDTH (f) : new_width;
       new_text_height = (new_height == 0) ? FRAME_TEXT_HEIGHT (f) : new_height;
-      /* Consider rounding here: Currently, the root window can be
-        larger than the frame in terms of columns/lines.  */
-      new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
-      new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
     }
   else
     {
@@ -5555,6 +5554,12 @@
   /* Compute width of windows in F.  */
   /* Round up to the smallest acceptable size.  */
   check_frame_size (f, &new_text_width, &new_text_height, 1);
+  /* Recompute the dimensions in character units, since
+     check_frame_size might have changed the pixel dimensions.  */
+  /* Consider rounding here: Currently, the root window can be
+     larger than the frame in terms of columns/lines.  */
+  new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
+  new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
 
   /* This is the width of the frame without vertical scroll bars and
      fringe columns.  Do this after rounding - see discussion of

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2014-09-16 15:53:36 +0000
+++ b/src/w32term.c     2014-09-24 07:31:11 +0000
@@ -4754,34 +4754,42 @@
              RECT rect;
              int rows, columns, width, height, text_width, text_height;
 
-             GetClientRect (msg.msg.hwnd, &rect);
-
-             height = rect.bottom - rect.top;
-             width = rect.right - rect.left;
-             text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, width);
-             text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, height);
-             rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
-             columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
-
-             /* TODO: Clip size to the screen dimensions.  */
-
-             /* Even if the number of character rows and columns has
-                not changed, the font size may have changed, so we need
-                to check the pixel dimensions as well.  */
-
-             if (width != FRAME_PIXEL_WIDTH (f)
-                 || height != FRAME_PIXEL_HEIGHT (f)
-                 || text_width != FRAME_TEXT_WIDTH (f)
-                 || text_height != FRAME_TEXT_HEIGHT (f))
+             if (GetClientRect (msg.msg.hwnd, &rect)
+                 /* GetClientRect evidently returns (0, 0, 0, 0) if
+                    called on a minimized frame.  Such "dimensions"
+                    aren't useful anyway.  */
+                 && !(rect.bottom == 0
+                      && rect.top == 0
+                      && rect.left == 0
+                      && rect.right == 0))
                {
-                 change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
-                 SET_FRAME_GARBAGED (f);
-                 cancel_mouse_face (f);
-                 /* Do we want to set these here ????  */
-/**              FRAME_PIXEL_WIDTH (f) = width; **/
-/**              FRAME_TEXT_WIDTH (f) = text_width; **/
-/**              FRAME_PIXEL_HEIGHT (f) = height; **/
-                 f->win_gravity = NorthWestGravity;
+                 height = rect.bottom - rect.top;
+                 width = rect.right - rect.left;
+                 text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, width);
+                 text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, height);
+                 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
+                 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
+
+                 /* TODO: Clip size to the screen dimensions.  */
+
+                 /* Even if the number of character rows and columns
+                    has not changed, the font size may have changed,
+                    so we need to check the pixel dimensions as well.  */
+
+                 if (width != FRAME_PIXEL_WIDTH (f)
+                     || height != FRAME_PIXEL_HEIGHT (f)
+                     || text_width != FRAME_TEXT_WIDTH (f)
+                     || text_height != FRAME_TEXT_HEIGHT (f))
+                   {
+                     change_frame_size (f, text_width, text_height, 0, 1, 0, 
1);
+                     SET_FRAME_GARBAGED (f);
+                     cancel_mouse_face (f);
+                     /* Do we want to set these here ????  */
+                     /**               FRAME_PIXEL_WIDTH (f) = width; **/
+                     /**               FRAME_TEXT_WIDTH (f) = text_width; **/
+                     /**               FRAME_PIXEL_HEIGHT (f) = height; **/
+                     f->win_gravity = NorthWestGravity;
+                   }
                }
            }
 


reply via email to

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