util/stanza.lua
changeset 9220 7df29c5fbb9b
parent 9002 a2a4c225a3f8
child 9310 feaef6215bb8
--- a/util/stanza.lua	Sun Aug 19 21:29:52 2018 +0100
+++ b/util/stanza.lua	Sun Aug 19 21:56:33 2018 +0100
@@ -217,6 +217,7 @@
 function stanza_mt:maptags(callback)
 	local tags, curr_tag = self.tags, 1;
 	local n_children, n_tags = #self, #tags;
+	local max_iterations = n_children + 1;
 
 	local i = 1;
 	while curr_tag <= n_tags and n_tags > 0 do
@@ -236,6 +237,11 @@
 			curr_tag = curr_tag + 1;
 		end
 		i = i + 1;
+		if i > max_iterations then
+			-- COMPAT: Hopefully temporary guard against #981 while we
+			-- figure out the root cause
+			error("Invalid stanza state! Please report this error.");
+		end
 	end
 	return self;
 end