From: Hirohito Higashi Date: Sat, 1 Aug 2026 13:26:21 +0000 (+0000) Subject: patch 9.2.0891: MS-Windows: filename-modifier ":8:t" causes underflow X-Git-Tag: v9.2.0891^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3df0ea61b708534fb0a2277216adaacf79ece43;p=thirdparty%2Fvim.git 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) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/src/filepath.c b/src/filepath.c index 8bdba335c6..e70b9c300b 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 b3d7b82be5..a1d9d9816e 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 09996f74bd..c48aca0ff4 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, /**/