comparison src/session.c @ 22230:0bbc8be90207 v8.2.1664

patch 8.2.1664: memory leak when using :mkview with a terminal buffer Commit: https://github.com/vim/vim/commit/c2c820563441499892359da949db3c8f7f16d109 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 11 22:10:22 2020 +0200 patch 8.2.1664: memory leak when using :mkview with a terminal buffer Problem: Memory leak when using :mkview with a terminal buffer. Solution: Don't use a hastab for :mkview. (Rob Pilling, closes https://github.com/vim/vim/issues/6935)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Sep 2020 22:15:03 +0200
parents 4ed106deb772
children e82579016863
comparison
equal deleted inserted replaced
22229:9bad0d1cde0e 22230:0bbc8be90207
301 */ 301 */
302 static int 302 static int
303 put_view( 303 put_view(
304 FILE *fd, 304 FILE *fd,
305 win_T *wp, 305 win_T *wp,
306 int add_edit, // add ":edit" command to view 306 int add_edit, // add ":edit" command to view
307 unsigned *flagp, // vop_flags or ssop_flags 307 unsigned *flagp, // vop_flags or ssop_flags
308 int current_arg_idx // current argument index of the window, use 308 int current_arg_idx, // current argument index of the window,
309 // -1 if unknown 309 // use -1 if unknown
310 #ifdef FEAT_TERMINAL 310 hashtab_T *terminal_bufs UNUSED) // already encountered terminal buffers,
311 , hashtab_T *terminal_bufs 311 // can be NULL
312 #endif
313 )
314 { 312 {
315 win_T *save_curwin; 313 win_T *save_curwin;
316 int f; 314 int f;
317 int do_cursor; 315 int do_cursor;
318 int did_next = FALSE; 316 int did_next = FALSE;
823 // Restore the view of the window (options, file, cursor, etc.). 821 // Restore the view of the window (options, file, cursor, etc.).
824 for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) 822 for (wp = tab_firstwin; wp != NULL; wp = wp->w_next)
825 { 823 {
826 if (!ses_do_win(wp)) 824 if (!ses_do_win(wp))
827 continue; 825 continue;
828 if (put_view(fd, wp, wp != edited_win, &ssop_flags, cur_arg_idx 826 if (put_view(fd, wp, wp != edited_win, &ssop_flags, cur_arg_idx,
829 #ifdef FEAT_TERMINAL 827 #ifdef FEAT_TERMINAL
830 , &terminal_bufs 828 &terminal_bufs
829 #else
830 NULL
831 #endif 831 #endif
832 ) == FAIL) 832 ) == FAIL)
833 goto fail; 833 goto fail;
834 if (nr > 1 && put_line(fd, "wincmd w") == FAIL) 834 if (nr > 1 && put_line(fd, "wincmd w") == FAIL)
835 goto fail; 835 goto fail;
1099 #ifdef FEAT_SESSION 1099 #ifdef FEAT_SESSION
1100 int view_session = FALSE; 1100 int view_session = FALSE;
1101 int using_vdir = FALSE; // using 'viewdir'? 1101 int using_vdir = FALSE; // using 'viewdir'?
1102 char_u *viewFile = NULL; 1102 char_u *viewFile = NULL;
1103 unsigned *flagp; 1103 unsigned *flagp;
1104 #endif
1105 #ifdef FEAT_TERMINAL
1106 hashtab_T terminal_bufs;
1107
1108 hash_init(&terminal_bufs);
1109 #endif 1104 #endif
1110 1105
1111 if (eap->cmdidx == CMD_mksession || eap->cmdidx == CMD_mkview) 1106 if (eap->cmdidx == CMD_mksession || eap->cmdidx == CMD_mkview)
1112 { 1107 {
1113 #ifdef FEAT_SESSION 1108 #ifdef FEAT_SESSION
1261 vim_free(dirnow); 1256 vim_free(dirnow);
1262 } 1257 }
1263 } 1258 }
1264 else 1259 else
1265 { 1260 {
1266 failed |= (put_view(fd, curwin, !using_vdir, flagp, -1 1261 failed |= (put_view(fd, curwin, !using_vdir, flagp, -1, NULL)
1267 #ifdef FEAT_TERMINAL 1262 == FAIL);
1268 , &terminal_bufs
1269 #endif
1270 ) == FAIL);
1271 } 1263 }
1272 if (put_line(fd, "let &so = s:so_save | let &siso = s:siso_save") 1264 if (put_line(fd, "let &so = s:so_save | let &siso = s:siso_save")
1273 == FAIL) 1265 == FAIL)
1274 failed = TRUE; 1266 failed = TRUE;
1275 #ifdef FEAT_SEARCH_EXTRA 1267 #ifdef FEAT_SEARCH_EXTRA