vim-patch:8.1.1897: may free memory twice when out of memory (#10827)

Problem:    May free memory twice when out of memory.
Solution:   Check that backslash_halve_save() returns a different pointer.
            (Dominique Pelle, closes vim/vim#4847)
f1552d07d7
This commit is contained in:
Jan Edmund Lazo
2019-08-22 00:49:33 -04:00
committed by Daniel Hahler
parent bb50eadc84
commit ed28668392
4 changed files with 21 additions and 16 deletions

View File

@@ -4212,24 +4212,24 @@ static int showmatches(expand_T *xp, int wildmenu)
|| xp->xp_context == EXPAND_BUFFERS) {
/* highlight directories */
if (xp->xp_numfiles != -1) {
char_u *halved_slash;
char_u *exp_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]);
// Expansion was done before and special characters
// were escaped, need to halve backslashes. Also
// $HOME has been replaced with ~/.
char_u *exp_path = expand_env_save_opt(files_found[k], true);
char_u *path = exp_path != NULL ? exp_path : files_found[k];
char_u *halved_slash = backslash_halve_save(path);
j = os_isdir(halved_slash);
xfree(exp_path);
xfree(halved_slash);
} else
/* Expansion was done here, file names are literal. */
if (halved_slash != path) {
xfree(halved_slash);
}
} else {
// Expansion was done here, file names are literal.
j = os_isdir(files_found[k]);
if (showtail)
}
if (showtail) {
p = L_SHOWFILE(k);
else {
} else {
home_replace(NULL, files_found[k], NameBuff, MAXPATHL,
TRUE);
p = NameBuff;