vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 1156af651f2baa7978c24c1de43b77c4bf3e2bab
parent 04766ba6c9872cc297293ac90c3098a2bd1e5ee4
Author: Karthin Srinavakili <karthin@karthin.com>
Date:   Mon,  4 Sep 2023 13:31:48 -0400

vis-lua: fail when mapping a key to an invalid handler type

When passing an invalid handler type (i.e., any type that isn't a
string, function, or KeyAction) to Vis:map/Window:map, the editor would
map the key to an empty (zeroed) KeyBinding struct.  vis_keys_process()
doesn't take this into account, so the key is never consumed from
the input queue, causing the editor to get stuck in an infinite loop.

Diffstat:
Mvis-lua.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/vis-lua.c b/vis-lua.c @@ -832,6 +832,8 @@ static int keymap(lua_State *L, Vis *vis, Win *win) { goto err; } else if (lua_isuserdata(L, 4)) { binding->action = obj_ref_check(L, 4, VIS_LUA_TYPE_KEYACTION); + } else { + goto err; } if (win) {