]> granicus.if.org Git - vim/commitdiff
patch 8.0.0331: restoring help snapshot accesses freed memory v8.0.0331
authorBram Moolenaar <Bram@vim.org>
Fri, 17 Feb 2017 11:04:56 +0000 (12:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 17 Feb 2017 11:04:56 +0000 (12:04 +0100)
Problem:    Restoring help snapshot accesses freed memory. (Dominique Pelle)
Solution:   Don't restore a snapshot when the window closes.

src/Makefile
src/testdir/Make_all.mak
src/testdir/test_help.vim [new file with mode: 0644]
src/version.c
src/window.c

index e1443e558292280e849ef256b57f1706b76b2824..153e526fdbd133bb1ec75024364a83f0634d432f 100644 (file)
@@ -2132,6 +2132,7 @@ test_arglist \
        test_goto \
        test_gui \
        test_hardcopy \
+       test_help \
        test_help_tagjump \
        test_hide \
        test_history \
index 58291ea75fef1b6a646274895451154807770c0f..3ff7247c3c1ac5ddafe4d2f914e280aee6e8863d 100644 (file)
@@ -154,6 +154,7 @@ NEW_TESTS = test_arglist.res \
            test_gn.res \
            test_gui.res \
            test_hardcopy.res \
+           test_help.res \
            test_hide.res \
            test_history.res \
            test_hlsearch.res \
diff --git a/src/testdir/test_help.vim b/src/testdir/test_help.vim
new file mode 100644 (file)
index 0000000..ca095d0
--- /dev/null
@@ -0,0 +1,10 @@
+" Tests for :help
+
+func Test_help_restore_snapshot()
+  help
+  set buftype=
+  help
+  edit x
+  help
+  helpclose
+endfunc
index 906c30c93f6e6da1c8cc1a7b6b185eae980d6710..b014e74c99706332acfaba12fe93b7e4c43447b4 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    331,
 /**/
     330,
 /**/
index 6b7bd353a41ab148ce69935ecde14b125084f3ed..c9771af58f71737555a0ddefc9852f2176936db1 100644 (file)
@@ -6551,7 +6551,7 @@ restore_snapshot(
 
 /*
  * Check if frames "sn" and "fr" have the same layout, same following frames
- * and same children.
+ * and same children.  And the window pointer is valid.
  */
     static int
 check_snapshot_rec(frame_T *sn, frame_T *fr)
@@ -6562,7 +6562,8 @@ check_snapshot_rec(frame_T *sn, frame_T *fr)
            || (sn->fr_next != NULL
                && check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL)
            || (sn->fr_child != NULL
-               && check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL))
+               && check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL)
+           || !win_valid(sn->fr_win))
        return FAIL;
     return OK;
 }