]> granicus.if.org Git - vim/commitdiff
patch 8.0.1404: invalid memory access on exit v8.0.1404
authorBram Moolenaar <Bram@vim.org>
Mon, 18 Dec 2017 15:21:44 +0000 (16:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 18 Dec 2017 15:21:44 +0000 (16:21 +0100)
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)

src/main.c
src/version.c

index e8006c30bd3fddc5f6b02d41929302d7f4039046..bfcc3e517b08ba8228bd4a3dca8b999f28b660c3 100644 (file)
@@ -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;
index 1ce42a91d5448543f59b754b1695f089bb159847..283a92c466b6358c0f87274068a4130e0971e6e3 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1404,
 /**/
     1403,
 /**/