summaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-10-11 19:27:47 +0200
committerBram Moolenaar <Bram@vim.org>2018-10-11 19:27:47 +0200
commit3d6014f0336d9a64c01a7518fe45fde0a925fa20 (patch)
tree7961f41f09ee54c2c240abac007ab9779709bb13 /src/fileio.c
parent108e7b422b7b59153dd5af1fb75e83fa36ff3db4 (diff)
patch 8.1.0470: pointer ownership around fname_expand() is unclearv8.1.0470
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.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 90f8517db1..4380067fd5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6187,7 +6187,8 @@ shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
|| buf->b_sfname == NULL
|| mch_isFullName(buf->b_sfname)))
{
- VIM_CLEAR(buf->b_sfname);
+ if (buf->b_sfname != buf->b_ffname)
+ VIM_CLEAR(buf->b_sfname);
p = shorten_fname(buf->b_ffname, dirname);
if (p != NULL)
{