mirror of
https://github.com/vim/vim.git
synced 2025-07-24 10:45:12 -04:00
patch 8.1.0066: nasty autocommand causes using freed memory
Problem: Nasty autocommand causes using freed memory. (Dominique Pelle) Solution: Do not force executing autocommands if the value of 'syntax' or 'filetype' did not change.
This commit is contained in:
parent
0e6e179f55
commit
c3ffc9b8d3
18
src/option.c
18
src/option.c
@ -6029,7 +6029,7 @@ did_set_string_option(
|
|||||||
/* set when changing an option that only requires a redraw in the GUI */
|
/* set when changing an option that only requires a redraw in the GUI */
|
||||||
int redraw_gui_only = FALSE;
|
int redraw_gui_only = FALSE;
|
||||||
#endif
|
#endif
|
||||||
int ft_changed = FALSE;
|
int value_changed = FALSE;
|
||||||
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
|
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
|
||||||
int did_swaptcap = FALSE;
|
int did_swaptcap = FALSE;
|
||||||
#endif
|
#endif
|
||||||
@ -7437,7 +7437,7 @@ did_set_string_option(
|
|||||||
if (!valid_filetype(*varp))
|
if (!valid_filetype(*varp))
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
else
|
else
|
||||||
ft_changed = STRCMP(oldval, *varp) != 0;
|
value_changed = STRCMP(oldval, *varp) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_SYN_HL
|
#ifdef FEAT_SYN_HL
|
||||||
@ -7445,6 +7445,8 @@ did_set_string_option(
|
|||||||
{
|
{
|
||||||
if (!valid_filetype(*varp))
|
if (!valid_filetype(*varp))
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
|
else
|
||||||
|
value_changed = STRCMP(oldval, *varp) != 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -7565,20 +7567,24 @@ did_set_string_option(
|
|||||||
/* When 'syntax' is set, load the syntax of that name */
|
/* When 'syntax' is set, load the syntax of that name */
|
||||||
if (varp == &(curbuf->b_p_syn))
|
if (varp == &(curbuf->b_p_syn))
|
||||||
{
|
{
|
||||||
|
// Only pass TRUE for "force" when the value changed, to avoid
|
||||||
|
// endless recurrence. */
|
||||||
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
|
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
|
||||||
curbuf->b_fname, TRUE, curbuf);
|
curbuf->b_fname, value_changed, curbuf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (varp == &(curbuf->b_p_ft))
|
else if (varp == &(curbuf->b_p_ft))
|
||||||
{
|
{
|
||||||
/* 'filetype' is set, trigger the FileType autocommand.
|
/* 'filetype' is set, trigger the FileType autocommand.
|
||||||
* Skip this when called from a modeline and the filetype was
|
* Skip this when called from a modeline and the filetype was
|
||||||
* already set to this value. */
|
* already set to this value.
|
||||||
if (!(opt_flags & OPT_MODELINE) || ft_changed)
|
* Only pass TRUE for "force" when the value changed, to avoid
|
||||||
|
* endless recurrence. */
|
||||||
|
if (!(opt_flags & OPT_MODELINE) || value_changed)
|
||||||
{
|
{
|
||||||
did_filetype = TRUE;
|
did_filetype = TRUE;
|
||||||
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
|
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
|
||||||
curbuf->b_fname, TRUE, curbuf);
|
curbuf->b_fname, value_changed, curbuf);
|
||||||
/* Just in case the old "curbuf" is now invalid. */
|
/* Just in case the old "curbuf" is now invalid. */
|
||||||
if (varp != &(curbuf->b_p_ft))
|
if (varp != &(curbuf->b_p_ft))
|
||||||
varp = NULL;
|
varp = NULL;
|
||||||
|
@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
66,
|
||||||
/**/
|
/**/
|
||||||
65,
|
65,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user