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.
diff --git a/src/fileio.c b/src/fileio.c
index 90f8517..4380067 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6187,7 +6187,8 @@
|| 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)
{