From 7ffe7ef6ba59f3ac5728dc7b782de5082e22aad9 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 8 Apr 2013 14:04:58 -0400 Subject: [PATCH] * src/window.c (select_window): Don't record_buffer while the invariant is temporarily broken. * src/fns.c (Fdelq): Don't assume !NILP => CONSP. Fixes: debbugs:14161 --- src/ChangeLog | 7 +++++++ src/fns.c | 2 +- src/keyboard.c | 10 +++++----- src/window.c | 17 ++++++++++------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index cb6930f9acc..04dcee7b6eb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2013-04-08 Stefan Monnier + + * window.c (select_window): Don't record_buffer while the invariant is + temporarily broken (bug#14161). + + * fns.c (Fdelq): Don't assume !NILP => CONSP. + 2013-04-07 Eli Zaretskii * fileio.c (ACL_NOT_WELL_SUPPORTED): Define macro for WINDOWSNT. diff --git a/src/fns.c b/src/fns.c index 86bdc0250dc..08c6f055f38 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1551,7 +1551,7 @@ the value of a list `foo'. */) tail = list; prev = Qnil; - while (!NILP (tail)) + while (CONSP (tail)) { CHECK_LIST_CONS (tail, list); tem = XCAR (tail); diff --git a/src/keyboard.c b/src/keyboard.c index beba3025887..b4fafa22e41 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -72,7 +72,7 @@ along with GNU Emacs. If not, see . */ #include TERM_HEADER #endif /* HAVE_WINDOW_SYSTEM */ -/* Variables for blockinput.h: */ +/* Variables for blockinput.h: */ /* Positive if interrupt input is blocked right now. */ volatile int interrupt_input_blocked; @@ -4337,10 +4337,10 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers) } idle_timer_ripe = EMACS_TIME_LE (idle_timer_time, idleness_now); - idle_timer_difference = - (idle_timer_ripe - ? sub_emacs_time (idleness_now, idle_timer_time) - : sub_emacs_time (idle_timer_time, idleness_now)); + idle_timer_difference + = (idle_timer_ripe + ? sub_emacs_time (idleness_now, idle_timer_time) + : sub_emacs_time (idle_timer_time, idleness_now)); } /* Decide which timer is the next timer, diff --git a/src/window.c b/src/window.c index feb5f7b5cc7..2ddf742be99 100644 --- a/src/window.c +++ b/src/window.c @@ -485,12 +485,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) w = XWINDOW (window); w->frozen_window_start_p = 0; - if (NILP (norecord)) - { - w->use_time = ++window_select_count; - record_buffer (w->contents); - } - /* Make the selected window's buffer current. */ Fset_buffer (w->contents); @@ -515,6 +509,15 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) select_window_1 (window, inhibit_point_swap); + /* record_buffer can run QUIT, so make sure it is run only after we have + re-established the invariant between selected_window and selected_frame, + otherwise the temporary broken invariant might "escape" (bug#14161). */ + if (NILP (norecord)) + { + w->use_time = ++window_select_count; + record_buffer (w->contents); + } + bset_last_selected_window (XBUFFER (w->contents), window); windows_or_buffers_changed++; return window; @@ -2929,7 +2932,7 @@ window-start value is reasonable when this function is called. */) replace_window (root, window, 1); - /* This must become SWINDOW anyway ....... */ + /* This must become SWINDOW anyway ....... */ if (BUFFERP (w->contents) && !resize_failed) { /* Try to minimize scrolling, by setting the window start to the -- 2.39.2