aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-19 21:58:33 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-19 22:52:30 -0500
commit7390cc8b2905a5831ad870a240496b8c355fa9b1 (patch)
treeabfa1cdc27e30e8a7163de34d1af0a3125072c8b /src/nvim/fileio.c
parente465157ecd8b49d71ad9b59f24c7aef33a9c402d (diff)
downloadrneovim-7390cc8b2905a5831ad870a240496b8c355fa9b1.tar.gz
rneovim-7390cc8b2905a5831ad870a240496b8c355fa9b1.tar.bz2
rneovim-7390cc8b2905a5831ad870a240496b8c355fa9b1.zip
vim-patch:8.1.0470: pointer ownership around fname_expand() is unclear
Problem: Pointer ownership around fname_expand() is unclear. Solution: Allow b_ffname and b_sfname to point to the same allocated memory, only free one. Update comments. https://github.com/vim/vim/commit/3d6014f0336d9a64c01a7518fe45fde0a925fa20
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index f4dd90fad2..3a84b5d41c 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -4217,7 +4217,9 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
&& (force
|| buf->b_sfname == NULL
|| path_is_absolute(buf->b_sfname))) {
- XFREE_CLEAR(buf->b_sfname);
+ if (buf->b_sfname != buf->b_ffname) {
+ XFREE_CLEAR(buf->b_sfname);
+ }
p = path_shorten_fname(buf->b_ffname, dirname);
if (p != NULL) {
buf->b_sfname = vim_strsave(p);