From af770ef9896c2d2078b3013f6666ffc41f6edf51 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 17 Feb 2015 15:58:03 +0000 Subject: [PATCH] Don't lua_call evalfn in MJLuaRunString() if it's not a function. If it's a string, which means it's an error, NSLog() it --- Hammerspoon/MJLua.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Hammerspoon/MJLua.m b/Hammerspoon/MJLua.m index ecd4ff01f..a9ac697d6 100644 --- a/Hammerspoon/MJLua.m +++ b/Hammerspoon/MJLua.m @@ -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);