Skip to content

Commit

Permalink
Don't lua_call evalfn in MJLuaRunString() if it's not a function. If …
Browse files Browse the repository at this point in the history
…it's a string, which means it's an error, NSLog() it
  • Loading branch information
cmsj committed Feb 17, 2015
1 parent 1dbf0fa commit af770ef
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Hammerspoon/MJLua.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ void MJLuaTeardown(void) {
lua_State* L = MJLuaState;

lua_rawgeti(L, LUA_REGISTRYINDEX, evalfn);
if (!lua_isfunction(L, -1)) {
NSLog(@"ERROR: MJLuaRunString doesn't seem to have an evalfn");
if (lua_isstring(L, -1)) {
NSLog(@"evalfn appears to be a string: %s", lua_tostring(L, -1));
}
return @"";
}
lua_pushstring(L, [command UTF8String]);
lua_call(L, 1, 1);

Expand Down

0 comments on commit af770ef

Please sign in to comment.