forked from aniani/vim
patch 8.2.5079: DirChanged autocommand may use freed memory
Problem: DirChanged autocommand may use freed memory. (Shane-XB Qian) Solution: Free the memory later. (closes #10555)
This commit is contained in:
@@ -7525,6 +7525,7 @@ changedir_func(
|
||||
int dir_differs;
|
||||
char_u *acmd_fname = NULL;
|
||||
char_u **pp;
|
||||
char_u *tofree;
|
||||
|
||||
if (new_dir == NULL || allbuf_locked())
|
||||
return FALSE;
|
||||
@@ -7601,13 +7602,14 @@ changedir_func(
|
||||
pp = &curtab->tp_prevdir;
|
||||
else
|
||||
pp = &prev_dir;
|
||||
vim_free(*pp);
|
||||
tofree = *pp; // new_dir may use this
|
||||
*pp = pdir;
|
||||
|
||||
post_chdir(scope);
|
||||
|
||||
if (dir_differs)
|
||||
apply_autocmds(EVENT_DIRCHANGED, acmd_fname, new_dir, FALSE, curbuf);
|
||||
vim_free(tofree);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user