From 0e3136f424075c8b5c97151f493e04f4235d8b62 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 19 Aug 2012 05:48:25 -0300 Subject: [PATCH] Fix stackoverflow caused by new table.copy --- modules/corelib/table.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/corelib/table.lua b/modules/corelib/table.lua index 572bd2d6..a5ebae80 100644 --- a/modules/corelib/table.lua +++ b/modules/corelib/table.lua @@ -14,10 +14,18 @@ function table.dump(t, depth) end function table.copy(t) + local res = {} + for k,v in pairs(t) do + res[k] = v + end + return res +end + +function table.recursivecopy(t) local res = {} for k,v in pairs(t) do if type(v) == "table" then - res[k] = table.copy(v) + res[k] = table.recursivecopy(v) else res[k] = v end @@ -83,4 +91,4 @@ function table.empty(t) return next(t) == nil end return true -end \ No newline at end of file +end