Skip to content

Commit 343b8c0

Browse files
committed
patch 8.0.0331: restoring help snapshot accesses freed memory
Problem: Restoring help snapshot accesses freed memory. (Dominique Pelle) Solution: Don't restore a snapshot when the window closes.
1 parent 84b2a38 commit 343b8c0

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ test_arglist \
21322132
test_goto \
21332133
test_gui \
21342134
test_hardcopy \
2135+
test_help \
21352136
test_help_tagjump \
21362137
test_hide \
21372138
test_history \

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ NEW_TESTS = test_arglist.res \
154154
test_gn.res \
155155
test_gui.res \
156156
test_hardcopy.res \
157+
test_help.res \
157158
test_hide.res \
158159
test_history.res \
159160
test_hlsearch.res \

src/testdir/test_help.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
" Tests for :help
2+
3+
func Test_help_restore_snapshot()
4+
help
5+
set buftype=
6+
help
7+
edit x
8+
help
9+
helpclose
10+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
331,
767769
/**/
768770
330,
769771
/**/

src/window.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6551,7 +6551,7 @@ restore_snapshot(
65516551

65526552
/*
65536553
* Check if frames "sn" and "fr" have the same layout, same following frames
6554-
* and same children.
6554+
* and same children. And the window pointer is valid.
65556555
*/
65566556
static int
65576557
check_snapshot_rec(frame_T *sn, frame_T *fr)
@@ -6562,7 +6562,8 @@ check_snapshot_rec(frame_T *sn, frame_T *fr)
65626562
|| (sn->fr_next != NULL
65636563
&& check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL)
65646564
|| (sn->fr_child != NULL
6565-
&& check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL))
6565+
&& check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL)
6566+
|| !win_valid(sn->fr_win))
65666567
return FAIL;
65676568
return OK;
65686569
}

0 commit comments

Comments
 (0)