comparison src/popupwin.c @ 19540:9f07a6c172f2 v8.2.0327

patch 8.2.0327: crash when opening and closing two popup terminal windows Commit: https://github.com/vim/vim/commit/80ae880f5fed8022c69d05dd1efee49259929cb5 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 28 19:11:18 2020 +0100 patch 8.2.0327: crash when opening and closing two popup terminal windows Problem: Crash when opening and closing two popup terminal windows. Solution: Check that prevwin is valid. (closes https://github.com/vim/vim/issues/5707)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Feb 2020 19:15:04 +0100
parents b70fbf3f0e0b
children 9e428147e4ee
comparison
equal deleted inserted replaced
19539:a31e293bd464 19540:9f07a6c172f2
2112 int id = wp->w_id; 2112 int id = wp->w_id;
2113 2113
2114 #ifdef FEAT_TERMINAL 2114 #ifdef FEAT_TERMINAL
2115 if (wp == curwin && curbuf->b_term != NULL) 2115 if (wp == curwin && curbuf->b_term != NULL)
2116 { 2116 {
2117 // Closing popup window with a terminal: put focus back on the previous 2117 win_T *owp;
2118 // window. 2118
2119 win_enter(prevwin, FALSE); 2119 // Closing popup window with a terminal: put focus back on the first
2120 // that works:
2121 // - another popup window with a terminal
2122 // - the previous window
2123 // - the first one.
2124 for (owp = first_popupwin; owp != NULL; owp = owp->w_next)
2125 if (owp != curwin && owp->w_buffer->b_term != NULL)
2126 break;
2127 if (owp != NULL)
2128 win_enter(owp, FALSE);
2129 else
2130 {
2131 for (owp = curtab->tp_first_popupwin; owp != NULL;
2132 owp = owp->w_next)
2133 if (owp != curwin && owp->w_buffer->b_term != NULL)
2134 break;
2135 if (owp != NULL)
2136 win_enter(owp, FALSE);
2137 else if (win_valid(prevwin))
2138 win_enter(prevwin, FALSE);
2139 else
2140 win_enter(firstwin, FALSE);
2141 }
2120 } 2142 }
2121 #endif 2143 #endif
2122 2144
2123 // Just in case a check higher up is missing. 2145 // Just in case a check higher up is missing.
2124 if (wp == curwin && ERROR_IF_POPUP_WINDOW) 2146 if (wp == curwin && ERROR_IF_POPUP_WINDOW)