[lua] Fix crash when setting layer.parent to nil

This commit is contained in:
David Capello 2020-05-28 15:12:26 -03:00
parent 896387635b
commit 0fc4989419

View File

@ -331,7 +331,9 @@ int Layer_set_parent(lua_State* L)
return luaL_error(L, "the given parent is not a layer group or sprite");
}
if (parent == layer)
if (!parent)
return luaL_error(L, "parent cannot be nil");
else if (parent == layer)
return luaL_error(L, "the parent of a layer cannot be the layer itself");
// TODO Why? should we be able to do this? It would require some hard work: