mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.1897: may free memory twice when out of memory
Problem: May free memory twice when out of memory. Solution: Check that backslash_halve_save() returns a different pointer. (Dominique Pelle, closes #4847)
This commit is contained in:
parent
eaf3524119
commit
f1552d07d7
@ -646,17 +646,19 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
|
||||
{
|
||||
char_u *halved_slash;
|
||||
char_u *exp_path;
|
||||
char_u *path;
|
||||
|
||||
// Expansion was done before and special characters
|
||||
// were escaped, need to halve backslashes. Also
|
||||
// $HOME has been replaced with ~/.
|
||||
exp_path = expand_env_save_opt(files_found[k], TRUE);
|
||||
halved_slash = backslash_halve_save(
|
||||
exp_path != NULL ? exp_path : files_found[k]);
|
||||
path = exp_path != NULL ? exp_path : files_found[k];
|
||||
halved_slash = backslash_halve_save(path);
|
||||
j = mch_isdir(halved_slash != NULL ? halved_slash
|
||||
: files_found[k]);
|
||||
vim_free(exp_path);
|
||||
vim_free(halved_slash);
|
||||
if (halved_slash != path)
|
||||
vim_free(halved_slash);
|
||||
}
|
||||
else
|
||||
// Expansion was done here, file names are literal.
|
||||
|
@ -4086,7 +4086,9 @@ gen_expand_wildcards(
|
||||
addfile(&ga, t, flags | EW_DIR | EW_FILE);
|
||||
else
|
||||
addfile(&ga, t, flags);
|
||||
vim_free(t);
|
||||
|
||||
if (t != p)
|
||||
vim_free(t);
|
||||
}
|
||||
|
||||
#if defined(FEAT_SEARCHPATH)
|
||||
|
@ -765,6 +765,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1897,
|
||||
/**/
|
||||
1896,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user