From: Eli Zaretskii Date: Mon, 3 Jun 2013 19:28:13 +0000 (+0300) Subject: Fix crashes in a text-mode session on Windows. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~85^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9337e20653c80e332555d109b945180cf41171fa;p=emacs.git Fix crashes in a text-mode session on Windows. src/w32console.c (initialize_w32_display): Return the dimensions of the console window via 2 additional arguments, not via the current frame. This avoids crashes due to overrunning the bounds of frame's decode_mode_spec_buffer, which is not resized following the change of the frame dimensions from the initial 10x10. src/w32term.h (w32_initialize_display_info): Adjust prototype. src/term.c (init_tty): Take dimensions of the frame from the values returned by initialize_w32_display. --- diff --git a/src/ChangeLog b/src/ChangeLog index 491e5c38617..7fdd456c9a7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2013-06-03 Eli Zaretskii + * w32console.c (initialize_w32_display): Return the dimensions of + the console window via 2 additional arguments, not via the current + frame. This avoids crashes due to overrunning the bounds of + frame's decode_mode_spec_buffer, which is not resized following + the change of the frame dimensions from the initial 10x10. + + * w32term.h (w32_initialize_display_info): Adjust prototype. + + * term.c (init_tty): Take dimensions of the frame from the values + returned by initialize_w32_display. + * Makefile.in (GFILENOTIFY_CFLAGS, GFILENOTIFY_LIBS): New variables. (ALL_CFLAGS): Add $(GFILENOTIFY_CFLAGS). (LIBES): Add $(GFILENOTIFY_LIBS). diff --git a/src/term.c b/src/term.c index 28b944c6436..0bcef55947a 100644 --- a/src/term.c +++ b/src/term.c @@ -3189,12 +3189,13 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ #ifdef WINDOWSNT { struct frame *f = XFRAME (selected_frame); + int height, width; - initialize_w32_display (terminal); + initialize_w32_display (terminal, &width, &height); - FrameRows (tty) = FRAME_LINES (f); - FrameCols (tty) = FRAME_COLS (f); - tty->specified_window = FRAME_LINES (f); + FrameRows (tty) = height; + FrameCols (tty) = width; + tty->specified_window = height; FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; terminal->char_ins_del_ok = 1; diff --git a/src/w32console.c b/src/w32console.c index 06b2c7aa24e..ee92a593301 100644 --- a/src/w32console.c +++ b/src/w32console.c @@ -601,7 +601,7 @@ w32_face_attributes (struct frame *f, int face_id) } void -initialize_w32_display (struct terminal *term) +initialize_w32_display (struct terminal *term, int *width, int *height) { CONSOLE_SCREEN_BUFFER_INFO info; Mouse_HLInfo *hlinfo; @@ -722,23 +722,21 @@ initialize_w32_display (struct terminal *term) || info.srWindow.Right - info.srWindow.Left < 40 || info.srWindow.Right - info.srWindow.Left > 100))) { - FRAME_LINES (SELECTED_FRAME ()) = 25; - SET_FRAME_COLS (SELECTED_FRAME (), 80); + *height = 25; + *width = 80; } else if (w32_use_full_screen_buffer) { - FRAME_LINES (SELECTED_FRAME ()) = info.dwSize.Y; /* lines per page */ - SET_FRAME_COLS (SELECTED_FRAME (), info.dwSize.X); /* characters per line */ + *height = info.dwSize.Y; /* lines per page */ + *width = info.dwSize.X; /* characters per line */ } else { /* Lines per page. Use buffer coords instead of buffer size. */ - FRAME_LINES (SELECTED_FRAME ()) = 1 + info.srWindow.Bottom - - info.srWindow.Top; + *height = 1 + info.srWindow.Bottom - info.srWindow.Top; /* Characters per line. Use buffer coords instead of buffer size. */ - SET_FRAME_COLS (SELECTED_FRAME (), 1 + info.srWindow.Right - - info.srWindow.Left); + *width = 1 + info.srWindow.Right - info.srWindow.Left; } if (os_subtype == OS_NT) diff --git a/src/w32term.h b/src/w32term.h index 9c27c09d03d..be0b4a6f350 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -683,7 +683,7 @@ extern Lisp_Object w32_get_watch_object (void *); extern Lisp_Object lispy_file_action (DWORD); extern void w32_initialize_display_info (Lisp_Object); -extern void initialize_w32_display (struct terminal *); +extern void initialize_w32_display (struct terminal *, int *, int *); /* Keypad command key support. W32 doesn't have virtual keys defined for the function keys on the keypad (they are mapped to the standard