Skip to content

Commit

Permalink
vis-lua: raise an error when mapping to invalid handler types
Browse files Browse the repository at this point in the history
When passing an invalid handler type (such as nil) to Vis:map/Window:map, the
editor would map the key to an empty (zeroed) KeyBinding that would cause itself
to become unresponsive when processing the corresponding key.
  • Loading branch information
devkarthin committed Sep 12, 2023
1 parent de315f8 commit eeb4b14
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ 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 {
vis_binding_free(vis, binding);
luaL_argerror(L, 4, "invalid handler");
}

if (win) {
Expand Down

0 comments on commit eeb4b14

Please sign in to comment.