Mercurial > vim
comparison src/cmdexpand.c @ 17801:6582dda76821 v8.1.1897
patch 8.1.1897: may free memory twice when out of memory
commit https://github.com/vim/vim/commit/f1552d07d715b437d941659479942c2543b02bd4
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 21 12:54:18 2019 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 21 Aug 2019 13:00:03 +0200 |
parents | 04245f071792 |
children | fd6c8dc33152 |
comparison
equal
deleted
inserted
replaced
17800:ecad47058bfc | 17801:6582dda76821 |
---|---|
644 // highlight directories | 644 // highlight directories |
645 if (xp->xp_numfiles != -1) | 645 if (xp->xp_numfiles != -1) |
646 { | 646 { |
647 char_u *halved_slash; | 647 char_u *halved_slash; |
648 char_u *exp_path; | 648 char_u *exp_path; |
649 char_u *path; | |
649 | 650 |
650 // Expansion was done before and special characters | 651 // Expansion was done before and special characters |
651 // were escaped, need to halve backslashes. Also | 652 // were escaped, need to halve backslashes. Also |
652 // $HOME has been replaced with ~/. | 653 // $HOME has been replaced with ~/. |
653 exp_path = expand_env_save_opt(files_found[k], TRUE); | 654 exp_path = expand_env_save_opt(files_found[k], TRUE); |
654 halved_slash = backslash_halve_save( | 655 path = exp_path != NULL ? exp_path : files_found[k]; |
655 exp_path != NULL ? exp_path : files_found[k]); | 656 halved_slash = backslash_halve_save(path); |
656 j = mch_isdir(halved_slash != NULL ? halved_slash | 657 j = mch_isdir(halved_slash != NULL ? halved_slash |
657 : files_found[k]); | 658 : files_found[k]); |
658 vim_free(exp_path); | 659 vim_free(exp_path); |
659 vim_free(halved_slash); | 660 if (halved_slash != path) |
661 vim_free(halved_slash); | |
660 } | 662 } |
661 else | 663 else |
662 // Expansion was done here, file names are literal. | 664 // Expansion was done here, file names are literal. |
663 j = mch_isdir(files_found[k]); | 665 j = mch_isdir(files_found[k]); |
664 if (showtail) | 666 if (showtail) |