CLuaInstVideo::VideoCheckData(): Fix segfault when invalid parameter is passed

Origin commit data
------------------
Commit: ec2afe52a9
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-04-30 (Sat, 30 Apr 2016)
This commit is contained in:
Michael Liebmann
2016-04-30 19:01:30 +02:00
parent 726912412c
commit 5c80402d36

View File

@@ -48,7 +48,11 @@ CLuaInstVideo* CLuaInstVideo::getInstance()
CLuaVideo *CLuaInstVideo::VideoCheckData(lua_State *L, int n)
{
return *(CLuaVideo **) luaL_checkudata(L, n, LUA_VIDEO_CLASSNAME);
void* ret = luaL_testudata(L, n, LUA_VIDEO_CLASSNAME);
if (ret == NULL)
return NULL;
else
return *(CLuaVideo **) ret;
}
void CLuaInstVideo::LuaVideoRegister(lua_State *L)