diff --git a/src/gui/lua/lua_threads.cpp b/src/gui/lua/lua_threads.cpp index c4f7fdee3..6a63c8bd5 100644 --- a/src/gui/lua/lua_threads.cpp +++ b/src/gui/lua/lua_threads.cpp @@ -174,7 +174,7 @@ llthread_t *CLLThread::llthread_create(lua_State *L, const char *code, size_t co /* non-string error message. */ lua_pushfstring(L, "luaL_loadbuffer() failed to load Lua code: rc=%d", rc); } - /* llthread_destroy(_this); */ + llthread_destroy(_this); lua_error(L); return NULL; } diff --git a/src/gui/lua/lua_threads_functions.cpp b/src/gui/lua/lua_threads_functions.cpp index 3d8f210cc..ac8df53fb 100644 --- a/src/gui/lua/lua_threads_functions.cpp +++ b/src/gui/lua/lua_threads_functions.cpp @@ -263,7 +263,7 @@ int CLLThread::l_llthread_delete(lua_State *L) { llthread_t **pthis = (llthread_t **)luaL_checkudata(L, 1, LLTHREAD_TAG); luaL_argcheck (L, pthis != NULL, 1, "thread expected"); - if (*pthis == NULL) return 0; + if (pthis == NULL || *pthis == NULL) return 0; llthread_destroy(*pthis); *pthis = NULL; diff --git a/src/gui/lua/luainstance.cpp b/src/gui/lua/luainstance.cpp index 3a7f44ab3..6c7516e4a 100644 --- a/src/gui/lua/luainstance.cpp +++ b/src/gui/lua/luainstance.cpp @@ -625,8 +625,10 @@ CLuaData *CLuaInstance::CheckData(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); - if (!ud) + if (!ud) { fprintf(stderr, "[CLuaInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className); + return NULL; + } return *(CLuaData **)ud; // unbox pointer }