aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-07-17 01:55:10 +0300
committerZyX <kp-pav@yandex.ru>2017-07-17 01:55:10 +0300
commitf4744e18219726d2eaa57b26198166ea255c62a4 (patch)
treee32926c5133d02f55cc978a3ce73ce269a47ee77
parent2a6423eba732b005e277bac393f2246308dcc378 (diff)
downloadrneovim-f4744e18219726d2eaa57b26198166ea255c62a4.tar.gz
rneovim-f4744e18219726d2eaa57b26198166ea255c62a4.tar.bz2
rneovim-f4744e18219726d2eaa57b26198166ea255c62a4.zip
ex_getln: Do not goto color_cmdline_end without first cleaning up
The issue with debug mode was actually not cleaning up after `try_enter`: location `&tstate` was pointing to got invalidated and received some “garbage” (actually, values that got stored on the stack afterwards). But pointer to that garbage was still stored in `msg_list`, so next attempt to check it resulted in a crash.
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--test/functional/ui/cmdline_highlight_spec.lua36
2 files changed, 36 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 275e1b7fdd..1052053ddf 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2372,8 +2372,6 @@ static bool color_cmdline(void)
dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"),
&color_cb);
can_free_cb = true;
- } else {
- goto color_cmdline_end;
}
if (!try_leave(&tstate, &err) || !dgc_ret) {
goto color_cmdline_error;
diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua
index 62c0694c8c..0621b990de 100644
--- a/test/functional/ui/cmdline_highlight_spec.lua
+++ b/test/functional/ui/cmdline_highlight_spec.lua
@@ -121,6 +121,7 @@ before_each(function()
EOB={bold = true, foreground = Screen.colors.Blue1},
ERR={foreground = Screen.colors.Grey100, background = Screen.colors.Red},
SK={foreground = Screen.colors.Blue},
+ PE={bold = true, foreground = Screen.colors.SeaGreen4}
})
end)
@@ -453,6 +454,41 @@ describe('Ex commands coloring support', function()
curbufmeths.get_lines(0, -1, false))
eq('', funcs.execute('messages'))
end)
+ it('does not crash when using `n` in debug mode', function()
+ feed(':debug execute "echo 1"\n')
+ screen:expect([[
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ Entering Debug mode. Type "cont" to con|
+ tinue. |
+ cmd: execute "echo 1" |
+ >^ |
+ ]])
+ feed('n\n')
+ screen:expect([[
+ {EOB:~ }|
+ {EOB:~ }|
+ Entering Debug mode. Type "cont" to con|
+ tinue. |
+ cmd: execute "echo 1" |
+ >n |
+ 1 |
+ {PE:Press ENTER or type command to continue}^ |
+ ]])
+ feed('\n')
+ screen:expect([[
+ ^ |
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ |
+ ]])
+ end)
end)
-- TODO Specifically test for coloring in cmdline and expr modes