Commit: patch 9.2.0891: MS-Windows: filename-modifier ":8:t" causes underflow
Christian Brabandt <[email protected]> Sat, 1 Aug 2026 15:45:04 +0200
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0891: MS-Windows: filename-modifier ":8:t" causes underflow Commit: https://github.com/vim/vim/commit/a3df0ea61b708534fb0a2277216adaacf79ece43 Author: Hirohito Higashi <[email protected]> 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) <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> 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, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wqA1Q-007YXW-68%40256bit.org.