From 8154c77bef1327aca76b83a1ec5177510f6b4b7b Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 1 Oct 2020 16:53:21 +0900 Subject: screen.c: fix buffer overflow due to folding fixes #12988. --- test/functional/ui/fold_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui/fold_spec.lua') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index fe67b9f6b0..9877f30206 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -6,6 +6,8 @@ local feed_command = helpers.feed_command local insert = helpers.insert local funcs = helpers.funcs local meths = helpers.meths +local source = helpers.source +local assert_alive = helpers.assert_alive describe("folded lines", function() local screen @@ -357,4 +359,26 @@ describe("folded lines", function() | ]]} end) + + it('does not crash when foldtext is longer than columns #12988', function() + source([[ + function! MyFoldText() abort + return repeat('-', &columns + 100) + endfunction + ]]) + command('set foldtext=MyFoldText()') + feed("i") + feed("vkzf") + screen:expect{grid=[[ + {5:^---------------------------------------------}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + assert_alive() + end) end) -- cgit