patch 9.1.1027: no sanitize check when running linematch Commit: https://github.com/vim/vim/commit/ca307efe486670b76563a4a287bc94dace57fb74 Author: Jonathon <jonathonwh...@protonmail.com> Date: Fri Jan 17 13:37:35 2025 +0100
patch 9.1.1027: no sanitize check when running linematch Problem: no sanitize check when running linematch Solution: add sanitize check before applying the linematch algorithm, similar to diff_find_change() (Jonathon) closes: #16446 Signed-off-by: Jonathon <jonathonwh...@protonmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/diff.c b/src/diff.c index c348894ec..41d61b1b5 100644 --- a/src/diff.c +++ b/src/diff.c @@ -2351,7 +2351,8 @@ diff_check_with_linestatus(win_T *wp, linenr_T lnum, int *linestatus) // Don't run linematch when lnum is offscreen. Useful for scrollbind // calculations which need to count all the filler lines above the screen. if (lnum >= wp->w_topline && lnum < wp->w_botline - && !dp->is_linematched && diff_linematch(dp)) + && !dp->is_linematched && diff_linematch(dp) + && diff_check_sanity(curtab, dp)) run_linematch_algorithm(dp); if (dp->is_linematched) diff --git a/src/testdir/dumps/Test_linematch_3diffs2.dump b/src/testdir/dumps/Test_linematch_3diffs2.dump new file mode 100644 index 000000000..3a333e643 --- /dev/null +++ b/src/testdir/dumps/Test_linematch_3diffs2.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1|a+0#0000000#5fd7ff255|b|c|d|q| @17||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21 +| +0#0000e05#a8a8a8255@1|d+0#0000000#ffd7ff255|e|f| @19||+1&#ffffff0| +0#0000e05#a8a8a8255@1|d+0#0000000#ffd7ff255|e|f|q+2&#ff404010| +0&#ffd7ff255@17||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21 +| +0#0000e05#a8a8a8255@1|h+0#0000000#ffd7ff255|i|j|k|l+2&#ff404010|m| +0&#ffd7ff255@16||+1&#ffffff0| +0#0000e05#a8a8a8255@1|h+0#0000000#ffd7ff255|i|j|k| @17||+1&#ffffff0| +0#0000e05#a8a8a8255@1|h+0#0000000#ffd7ff255|i|j|k|l+2&#ff404010|m| +0&#ffd7ff255@15 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@22||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|n+0#0000000#ffd7ff255|o|p|q| @17||+1&#ffffff0| +0#0000e05#a8a8a8255@1|n+0#0000000#ffd7ff255|o|p|q|r+2&#ff404010| +0&#ffd7ff255@16 +| +0#0000e05#a8a8a8255@1> +0#0000000#ffd7ff255@22||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|s+2#0000000#ff404010|t|u|v| +0&#ffd7ff255@17 +|~+0#4040ff13#ffffff0| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 +|<+3#0000000&|e|m|a|t|c|h|1| |[|+|]| |4|,|1| @5|A|l@1| |<+1&&|l|i|n|e|m|a|t|c|h|2| |3|,|1| @5|A|l@1| |<|l|i|n|e|m|a|t|c|h|3| |3|,|1| @5|A|l@1 +|-+2&&@1| |I|N|S|E|R|T| |-@1| +0&&@62 diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim index 8939bb80c..36d3d9ba6 100644 --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -1265,7 +1265,7 @@ func CloseoffSetup() call setline(1, ['one', 'tow', 'three']) diffthis call assert_equal(1, &diff) - only! + bw! endfunc func Test_diff_closeoff() @@ -2529,7 +2529,8 @@ func Test_diffget_diffput_linematch() call term_sendkeys(buf, "17gg") call term_sendkeys(buf, ":diffput\<CR>") call VerifyScreenDump(buf, 'Test_diff_get_put_linematch_19', {}) - + " clean up + call StopVimInTerminal(buf) endfunc func Test_linematch_diff() @@ -2549,7 +2550,8 @@ func Test_linematch_diff() \ 'abc d!', \ 'd!']) call VerifyScreenDump(buf, 'Test_linematch_diff1', {}) - + " clean up + call StopVimInTerminal(buf) endfunc func Test_linematch_diff_iwhite() @@ -2575,7 +2577,8 @@ func Test_linematch_diff_iwhite() call VerifyScreenDump(buf, 'Test_linematch_diff_iwhite1', {}) call term_sendkeys(buf, ":set diffopt+=iwhiteall\<CR>") call VerifyScreenDump(buf, 'Test_linematch_diff_iwhite2', {}) - + " clean up + call StopVimInTerminal(buf) endfunc func Test_linematch_diff_grouping() @@ -2612,7 +2615,8 @@ func Test_linematch_diff_grouping() \ '?C', \ '?C']) call VerifyScreenDump(buf, 'Test_linematch_diff_grouping2', {}) - + " clean up + call StopVimInTerminal(buf) endfunc func Test_linematch_diff_scroll() @@ -2643,11 +2647,10 @@ func Test_linematch_diff_scroll() call VerifyScreenDump(buf, 'Test_linematch_diff_grouping_scroll1', {}) call term_sendkeys(buf, "3\<c-e>") call VerifyScreenDump(buf, 'Test_linematch_diff_grouping_scroll2', {}) - + " clean up + call StopVimInTerminal(buf) endfunc - - func Test_linematch_line_limit_exceeded() CheckScreendump call delete('.Xdifile1.swp') @@ -2694,7 +2697,8 @@ func Test_linematch_line_limit_exceeded() " alignment algorithm will run on the largest diff block here call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>") call VerifyScreenDump(buf, 'Test_linematch_line_limit_exceeded2', {}) - + " clean up + call StopVimInTerminal(buf) endfunc func Test_linematch_3diffs() @@ -2731,6 +2735,31 @@ func Test_linematch_3diffs() \ " BBB", \ " BBB"]) call VerifyScreenDump(buf, 'Test_linematch_3diffs1', {}) + " clean up + call StopVimInTerminal(buf) +endfunc +" this used to access invalid memory +func Test_linematch_3diffs_sanity_check() + CheckScreendump + call delete('.Xfile_linematch1.swp') + call delete('.Xfile_linematch2.swp') + call delete('.Xfile_linematch3.swp') + let lines =<< trim END + set diffopt+=linematch:60 + call feedkeys("Aq\<esc>") + call feedkeys("GAklm\<esc>") + call feedkeys("o") + END + call writefile(lines, 'Xlinematch_3diffs.vim', 'D') + call writefile(['abcd', 'def', 'hij'], 'Xfile_linematch1', 'D') + call writefile(['defq', 'hijk', 'nopq'], 'Xfile_linematch2', 'D') + call writefile(['hijklm', 'nopqr', 'stuv'], 'Xfile_linematch3', 'D') + call WriteDiffFiles3(0, [], [], []) + let buf = RunVimInTerminal('-d -S Xlinematch_3diffs.vim Xfile_linematch1 Xfile_linematch2 Xfile_linematch3', {}) + call VerifyScreenDump(buf, 'Test_linematch_3diffs2', {}) + + " clean up + call StopVimInTerminal(buf) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 46c4818b1..d6b73fd79 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1027, /**/ 1026, /**/ -- -- 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1tYlih-000UCB-GA%40256bit.org.