Fix crash when the constructor of a LuaComponent derivative fails

The interface API is a mess, hopefully not for long.
This commit is contained in:
Tamás Bálint Misius 2021-01-04 21:33:23 +01:00
parent 92ccb12d70
commit 1e67a579fd
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -18,7 +18,7 @@ int LuaComponentCallback::CheckAndAssignArg1(lua_State *l)
return 0;
}
LuaComponent::LuaComponent(lua_State * l) : owner_ref(LUA_REFNIL)
LuaComponent::LuaComponent(lua_State * l) : component(nullptr), owner_ref(LUA_REFNIL)
{
this->l = l; // I don't get how this doesn't cause crashes later on
@ -83,7 +83,7 @@ int LuaComponent::visible(lua_State * l)
LuaComponent::~LuaComponent()
{
if(component->GetParentWindow())
if(component && component->GetParentWindow())
component->GetParentWindow()->RemoveComponent(component);
delete component;
}