use pcall to avoid crash on decompress

This commit is contained in:
cpdef 2018-01-16 21:07:48 +01:00
parent 7e7edbad8d
commit 8dd9e77e97

View File

@ -350,10 +350,12 @@ minetest.register_craftitem("painting:paintedcanvas", {
local data = legacy.load_itemmeta(itemstack:get_metadata())
-- for backwards compatiblity
if not minetest.deserialize(data) then
data = minetest.decompress(data)
if data then
status, data = pcall(minetest.decompress(data))
if (status and data) then
print("tryed to save old data"..
"converted to new uncompressed, save")
elseif not status then
print("error loading data")
end
end
-- end backwards compatiblity