vim-patch:9.0.2010: [security] use-after-free from buf_contents_changed()

Problem:  [security] use-after-free from buf_contents_changed()
Solution: block autocommands

41e6f7d6ba

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2023-11-17 09:42:59 +08:00
parent b6200fbdf2
commit d49be1cd28
3 changed files with 15 additions and 0 deletions

View File

@@ -4223,6 +4223,10 @@ bool buf_contents_changed(buf_T *buf)
aco_save_T aco;
aucmd_prepbuf(&aco, newbuf);
// We don't want to trigger autocommands now, they may have nasty
// side-effects like wiping buffers
block_autocmds();
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
0, 0, (linenr_T)MAXLNUM,
@@ -4247,6 +4251,8 @@ bool buf_contents_changed(buf_T *buf)
wipe_buffer(newbuf, false);
}
unblock_autocmds();
return differ;
}