Permalink
Browse files

Fix a Lua stack overflow in the C callback MJLuaCompletionsForWord

  • Loading branch information...
cmsj committed Apr 10, 2018
1 parent 901b7ab commit 2b7abf2b33e3ddb17d87e548725959a8bba1ac40
Showing with 3 additions and 6 deletions.
  1. +3 −6 Hammerspoon/MJLua.m
@@ -787,19 +787,16 @@ void MJLuaDealloc(void) {
_lua_stackguard_entry(skin.L);
[skin pushLuaRef:refTable ref:completionsForWordFn];
if (!lua_isfunction(skin.L, -1)) {
HSNSLOG(@"ERROR: MJLuaCompletionsForWord doesn't seem to have a completionsForWordFn");
_lua_stackguard_exit(skin.L);
return @[];
}
[skin pushNSObject:completionWord];
if ([skin protectedCallAndError:@"MJLuaCompletionsForWord" nargs:1 nresults:1] == NO) {
_lua_stackguard_exit(skin.L);
return @[];
}
NSArray *completions = [skin toNSObjectAtIndex:-1];
lua_pop(skin.L, 1);
_lua_stackguard_exit(skin.L);
return [skin toNSObjectAtIndex:-1];
return completions;
}
// C-Code helper to return current active LuaState. Useful for callbacks to

0 comments on commit 2b7abf2

Please sign in to comment.