Skip to content

Commit b2c8750

Browse files
committed
patch 8.0.1193: crash when wiping out a buffer after using getbufinfo()
Problem: Crash when wiping out a buffer after using getbufinfo(). (Yegappan Lakshmanan) Solution: Remove b:changedtick from the buffer variables.
1 parent ac8069b commit b2c8750

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/buffer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ free_buffer(buf_T *buf)
837837
++buf_free_count;
838838
free_buffer_stuff(buf, TRUE);
839839
#ifdef FEAT_EVAL
840+
/* b:changedtick uses an item in buf_T, remove it now */
841+
dictitem_remove(buf->b_vars, (dictitem_T *)&buf->b_ct_di);
840842
unref_var_dict(buf->b_vars);
841843
#endif
842844
#ifdef FEAT_LUA

src/testdir/test_autocmd.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,10 +769,14 @@ func Test_BufLeave_Wipe()
769769
bwipe!
770770
call assert_equal(1, line('$'))
771771
call assert_equal('', bufname('%'))
772-
call assert_equal(1, len(getbufinfo()))
772+
let g:bufinfo = getbufinfo()
773+
call assert_equal(1, len(g:bufinfo))
773774

774775
call delete('Xxx1')
775776
call delete('Xxx2')
776777
%bwipe
777778
au! BufLeave
779+
780+
" check that bufinfo doesn't contain a pointer to freed memory
781+
call test_garbagecollect_now()
778782
endfunc

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1193,
764766
/**/
765767
1192,
766768
/**/

0 commit comments

Comments
 (0)