fixed possible stack overflow in deep_copy

This commit is contained in:
Max Cahill 2022-06-09 16:36:02 +10:00
parent a5c26038df
commit 81512550bb

View File

@ -361,11 +361,11 @@ local function _deep_copy_impl(t, already_copied)
else else
--a plain table to clone --a plain table to clone
clone = {} clone = {}
already_copied[t] = clone
for k, v in pairs(t) do for k, v in pairs(t) do
clone[k] = _deep_copy_impl(v, already_copied) clone[k] = _deep_copy_impl(v, already_copied)
end end
setmetatable(clone, getmetatable(t)) setmetatable(clone, getmetatable(t))
already_copied[t] = clone
end end
end end
return clone return clone