int ret = engine_pcall(L, 1);
if (ret != 0) {
fprintf(stderr, "error: %s\n", lua_tostring(L, -1));
- lua_pop(L, 1);
}
+ /* Clear the stack, there may be event a/o enything returned */
+ lua_settop(L, 0);
/* Free callback if not recurrent or an error */
if (ret != 0 || uv_timer_get_repeat(timer) == 0) {
uv_close((uv_handle_t *)timer, (uv_close_cb) event_free);
lua_getfield(L, -1, call);
lua_remove(L, -2);
if (lua_isnil(L, -1)) {
+ lua_pop(L, 1);
return NULL;
}
lua_pushlightuserdata(L, module);
/** @internal Helper for calling the entrypoint. */
static inline int l_ffi_call(lua_State *L, int argc)
{
- int status = lua_pcall(L, argc, LUA_MULTRET, 0);
+ int status = lua_pcall(L, argc, 1, 0);
if (status != 0) {
fprintf(stderr, "error: %s\n", lua_tostring(L, -1));
lua_pop(L, 1);
} else if (lua_isnumber(L, -1)) { /* Return code */
status = lua_tonumber(L, 1);
}
- lua_pop(L, n);
+ lua_pop(L, 1);
}
return status;
}