summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-12-18 16:21:44 +0100
committerBram Moolenaar <Bram@vim.org>2017-12-18 16:21:44 +0100
commit606d45ccd8a2ad2956e2729f6135fd79fd2f6d72 (patch)
tree586d018b4ed4ef70d146ce254996591f74b992cf /src/main.c
parent4fb921e388b9a042573ab06cce36e92874954197 (diff)
downloadvim-git-606d45ccd8a2ad2956e2729f6135fd79fd2f6d72.tar.gz
patch 8.0.1404: invalid memory access on exitv8.0.1404
Problem: Invalid memory access on exit when autocommands wipe out a buffer. (gy741, Dominique Pelle) Solution: Check if the buffer is still valid. (closes #2449)
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index e8006c30b..bfcc3e517 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1432,9 +1432,14 @@ getout(int exitval)
buf = wp->w_buffer;
if (CHANGEDTICK(buf) != -1)
{
+ bufref_T bufref;
+
+ set_bufref(&bufref, buf);
apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname,
buf->b_fname, FALSE, buf);
- CHANGEDTICK(buf) = -1; /* note that we did it already */
+ if (bufref_valid(&bufref))
+ CHANGEDTICK(buf) = -1; /* note we did it already */
+
/* start all over, autocommands may mess up the lists */
next_tp = first_tabpage;
break;