mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.2313
Problem: Crash when deleting an augroup and listing an autocommand.
(Dominique Pelle)
Solution: Make sure deleted_augroup is valid.
b62cc36a60
This commit is contained in:
parent
6f285226a9
commit
f8f04350bd
@ -5366,6 +5366,7 @@ static AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */
|
|||||||
*/
|
*/
|
||||||
static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
|
static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
|
||||||
#define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
|
#define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
|
||||||
|
// use get_deleted_augroup() to get this
|
||||||
static char_u *deleted_augroup = NULL;
|
static char_u *deleted_augroup = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5381,6 +5382,14 @@ static event_T last_event;
|
|||||||
static int last_group;
|
static int last_group;
|
||||||
static int autocmd_blocked = 0; /* block all autocmds */
|
static int autocmd_blocked = 0; /* block all autocmds */
|
||||||
|
|
||||||
|
static char_u *get_deleted_augroup(void)
|
||||||
|
{
|
||||||
|
if (deleted_augroup == NULL) {
|
||||||
|
deleted_augroup = (char_u *)_("--Deleted--");
|
||||||
|
}
|
||||||
|
return deleted_augroup;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show the autocommands for one AutoPat.
|
* Show the autocommands for one AutoPat.
|
||||||
*/
|
*/
|
||||||
@ -5401,7 +5410,7 @@ static void show_autocmd(AutoPat *ap, event_T event)
|
|||||||
if (event != last_event || ap->group != last_group) {
|
if (event != last_event || ap->group != last_group) {
|
||||||
if (ap->group != AUGROUP_DEFAULT) {
|
if (ap->group != AUGROUP_DEFAULT) {
|
||||||
if (AUGROUP_NAME(ap->group) == NULL) {
|
if (AUGROUP_NAME(ap->group) == NULL) {
|
||||||
msg_puts_attr(deleted_augroup, hl_attr(HLF_E));
|
msg_puts_attr(get_deleted_augroup(), hl_attr(HLF_E));
|
||||||
} else {
|
} else {
|
||||||
msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T));
|
msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T));
|
||||||
}
|
}
|
||||||
@ -5591,10 +5600,7 @@ static void au_del_group(char_u *name)
|
|||||||
}
|
}
|
||||||
xfree(AUGROUP_NAME(i));
|
xfree(AUGROUP_NAME(i));
|
||||||
if (in_use) {
|
if (in_use) {
|
||||||
if (deleted_augroup == NULL) {
|
AUGROUP_NAME(i) = get_deleted_augroup();
|
||||||
deleted_augroup = (char_u *)_("--Deleted--");
|
|
||||||
}
|
|
||||||
AUGROUP_NAME(i) = deleted_augroup;
|
|
||||||
} else {
|
} else {
|
||||||
AUGROUP_NAME(i) = NULL;
|
AUGROUP_NAME(i) = NULL;
|
||||||
}
|
}
|
||||||
@ -5610,7 +5616,7 @@ static int au_find_group(const char_u *name)
|
|||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
for (int i = 0; i < augroups.ga_len; i++) {
|
for (int i = 0; i < augroups.ga_len; i++) {
|
||||||
if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != deleted_augroup
|
if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != get_deleted_augroup()
|
||||||
&& STRCMP(AUGROUP_NAME(i), name) == 0) {
|
&& STRCMP(AUGROUP_NAME(i), name) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -5669,7 +5675,7 @@ void free_all_autocmds(void)
|
|||||||
|
|
||||||
for (i = 0; i < augroups.ga_len; i++) {
|
for (i = 0; i < augroups.ga_len; i++) {
|
||||||
s = ((char_u **)(augroups.ga_data))[i];
|
s = ((char_u **)(augroups.ga_data))[i];
|
||||||
if (s != deleted_augroup) {
|
if (s != get_deleted_augroup()) {
|
||||||
xfree(s);
|
xfree(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7135,7 +7141,7 @@ char_u *get_augroup_name(expand_T *xp, int idx)
|
|||||||
return (char_u *)"END";
|
return (char_u *)"END";
|
||||||
if (idx >= augroups.ga_len) /* end of list */
|
if (idx >= augroups.ga_len) /* end of list */
|
||||||
return NULL;
|
return NULL;
|
||||||
if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == deleted_augroup) {
|
if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == get_deleted_augroup()) {
|
||||||
// skip deleted entries
|
// skip deleted entries
|
||||||
return (char_u *)"";
|
return (char_u *)"";
|
||||||
}
|
}
|
||||||
@ -7198,7 +7204,7 @@ char_u *get_event_name(expand_T *xp, int idx)
|
|||||||
{
|
{
|
||||||
if (idx < augroups.ga_len) { // First list group names, if wanted
|
if (idx < augroups.ga_len) { // First list group names, if wanted
|
||||||
if (!include_groups || AUGROUP_NAME(idx) == NULL
|
if (!include_groups || AUGROUP_NAME(idx) == NULL
|
||||||
|| AUGROUP_NAME(idx) == deleted_augroup) {
|
|| AUGROUP_NAME(idx) == get_deleted_augroup()) {
|
||||||
return (char_u *)""; // skip deleted entries
|
return (char_u *)""; // skip deleted entries
|
||||||
}
|
}
|
||||||
return AUGROUP_NAME(idx); // return a name
|
return AUGROUP_NAME(idx); // return a name
|
||||||
|
@ -183,3 +183,12 @@ func Test_augroup_warning()
|
|||||||
redir END
|
redir END
|
||||||
call assert_true(match(res, "W19:") < 0)
|
call assert_true(match(res, "W19:") < 0)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_augroup_deleted()
|
||||||
|
" This caused a crash
|
||||||
|
augroup x
|
||||||
|
augroup! x
|
||||||
|
au VimEnter * echo
|
||||||
|
au VimEnter
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ static int included_patches[] = {
|
|||||||
// 2316 NA
|
// 2316 NA
|
||||||
// 2315,
|
// 2315,
|
||||||
// 2314,
|
// 2314,
|
||||||
// 2313,
|
2313,
|
||||||
2312,
|
2312,
|
||||||
// 2311 NA
|
// 2311 NA
|
||||||
// 2310 NA
|
// 2310 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user