Mercurial > vim
comparison src/quickfix.c @ 19649:d4baa35fea5d v8.2.0381
patch 8.2.0381: using freed memory with :lvimgrep and autocommand
Commit: https://github.com/vim/vim/commit/2573af3519ad062ddad647b97e32090f106f2ac1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 14 17:21:34 2020 +0100
patch 8.2.0381: using freed memory with :lvimgrep and autocommand
Problem: Using freed memory with :lvimgrep and autocommand. (extracted from
POC by Dominique Pelle)
Solution: Avoid deleting a dummy buffer used in a window. (closes #5777)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 Mar 2020 17:30:04 +0100 |
parents | 5512aa74cb62 |
children | 435726a03481 |
comparison
equal
deleted
inserted
replaced
19648:50689415194e | 19649:d4baa35fea5d |
---|---|
6266 * 'autochdir' option have changed it. | 6266 * 'autochdir' option have changed it. |
6267 */ | 6267 */ |
6268 static void | 6268 static void |
6269 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) | 6269 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) |
6270 { | 6270 { |
6271 if (curbuf != buf) // safety check | 6271 // If any autocommand opened a window on the dummy buffer, close that |
6272 // window. If we can't close them all then give up. | |
6273 while (buf->b_nwindows > 0) | |
6274 { | |
6275 int did_one = FALSE; | |
6276 win_T *wp; | |
6277 | |
6278 if (firstwin->w_next != NULL) | |
6279 for (wp = firstwin; wp != NULL; wp = wp->w_next) | |
6280 if (wp->w_buffer == buf) | |
6281 { | |
6282 if (win_close(wp, FALSE) == OK) | |
6283 did_one = TRUE; | |
6284 break; | |
6285 } | |
6286 if (!did_one) | |
6287 return; | |
6288 } | |
6289 | |
6290 if (curbuf != buf && buf->b_nwindows == 0) // safety check | |
6272 { | 6291 { |
6273 #if defined(FEAT_EVAL) | 6292 #if defined(FEAT_EVAL) |
6274 cleanup_T cs; | 6293 cleanup_T cs; |
6275 | 6294 |
6276 // Reset the error/interrupt/exception state here so that aborting() | 6295 // Reset the error/interrupt/exception state here so that aborting() |