Commit: patch 9.2.0891: MS-Windows: filename-modifier ":8:t" causes underflow

1 view
Skip to first unread message

Christian Brabandt

unread,
9:45 AM (11 hours ago) 9:45 AM
to vim...@googlegroups.com
patch 9.2.0891: MS-Windows: filename-modifier ":8:t" causes underflow

Commit: https://github.com/vim/vim/commit/a3df0ea61b708534fb0a2277216adaacf79ece43
Author: Hirohito Higashi <h.eas...@gmail.com>
Date: Sat Aug 1 13:26:21 2026 +0000

patch 9.2.0891: MS-Windows: filename-modifier ":8:t" causes underflow

Problem: On MS-Windows using ":8" with ":t", ":e" or ":r" in one
fnamemodify() gives a wrong result or an out of memory error.
Solution: Recompute the tail after ":8" replaced the name
(Hirohito Higashi).

related: #20899
closes: #20903

Co-Authored-By: Claude Opus 5 (1M context) <nor...@anthropic.com>
Signed-off-by: Hirohito Higashi <h.eas...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/filepath.c b/src/filepath.c
index 8bdba335c..e70b9c300 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -586,6 +586,10 @@ repeat:
}
*fnamelen = l;
}
+
+ // The name was replaced by the short name, "tail" points into the
+ // previous name.
+ tail = gettail(*fnamep);
}
#endif // MSWIN

diff --git a/src/testdir/test_shortpathname.vim b/src/testdir/test_shortpathname.vim
index b3d7b82be..a1d9d9816 100644
--- a/src/testdir/test_shortpathname.vim
+++ b/src/testdir/test_shortpathname.vim
@@ -101,4 +101,24 @@ func Test_ColonEight_notexists()
call assert_equal(non_exists, fnamemodify(non_exists, ':p:8'))
endfunc

+" ":8" replaces the name, the modifiers after it must use the new name.
+func Test_ColonEight_then_tail()
+ let dir = 'c:/Xtest_C8tail'
+ call s:SetupDir(dir)
+
+ let file = dir . '/longfilename.txt'
+
+ call mkdir(dir, 'D')
+ call writefile([], file, 'D')
+
+ let sfile = fnamemodify(file, ':p:8')
+ if sfile ==? fnamemodify(file, ':p')
+ throw 'Skipped: 8.3 short names are not created on this volume'
+ endif
+
+ call assert_equal(fnamemodify(sfile, ':t'), fnamemodify(file, ':p:8:t'))
+ call assert_equal(fnamemodify(sfile, ':e'), fnamemodify(file, ':p:8:e'))
+ call assert_equal(fnamemodify(sfile, ':r'), fnamemodify(file, ':p:8:r'))
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 09996f74b..c48aca0ff 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 891,
/**/
890,
/**/
Reply all
Reply to author
Forward
0 new messages