diff src/fileio.c @ 14917:6f2ce3b311de v8.1.0470

patch 8.1.0470: pointer ownership around fname_expand() is unclear commit https://github.com/vim/vim/commit/3d6014f0336d9a64c01a7518fe45fde0a925fa20 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 11 19:27:47 2018 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Thu, 11 Oct 2018 19:30:05 +0200
parents 27b9a84395b5
children 162d79d273e6
line wrap: on
line diff
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6187,7 +6187,8 @@ shorten_buf_fname(buf_T *buf, char_u *di
 		|| 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)
 	{