From cbabb9cdb401a65c4ad0bc7b4d9b2c4af4eeb032 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 9 Oct 2008 22:19:35 +0500 Subject: Fixed: util.stanza.deserialize now handles nil stanzas --- util/stanza.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'util') diff --git a/util/stanza.lua b/util/stanza.lua index a4fd0f82..6bc70ab9 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -122,21 +122,23 @@ end function deserialize(stanza) -- Set metatable - setmetatable(stanza, stanza_mt); - for _, child in ipairs(stanza) do - if type(child) == "table" then - deserialize(child); - end - end - if not stanza.tags then - -- Rebuild tags - local tags = {}; + if stanza then + setmetatable(stanza, stanza_mt); for _, child in ipairs(stanza) do if type(child) == "table" then - t_insert(tags, child); + deserialize(child); + end + end + if not stanza.tags then + -- Rebuild tags + local tags = {}; + for _, child in ipairs(stanza) do + if type(child) == "table" then + t_insert(tags, child); + end end + stanza.tags = tags; end - stanza.tags = tags; end return stanza; -- cgit v1.2.3