util.xmppstream: Explicitly release old parser object on stream reset
authorMatthew Wild <mwild1@gmail.com>
Tue, 31 Jul 2018 15:42:45 +0100
changeset 9074 db61e33bbd41
parent 9073 21730a3642fe
child 9075 9603a6a1ec85
util.xmppstream: Explicitly release old parser object on stream reset
util/xmppstream.lua
--- a/util/xmppstream.lua	Mon Jul 30 15:13:54 2018 +0100
+++ b/util/xmppstream.lua	Tue Jul 31 15:42:45 2018 +0100
@@ -278,10 +278,15 @@
 			if lxp_supports_bytecount then
 				n_outstanding_bytes = n_outstanding_bytes + #data;
 			end
-			local ok, err = parse(parser, data);
+			local _parser = parser;
+			local ok, err = parse(_parser, data);
 			if lxp_supports_bytecount and n_outstanding_bytes > stanza_size_limit then
 				return nil, "stanza-too-large";
 			end
+			if parser ~= _parser then
+				_parser:parse();
+				_parser:close();
+			end
 			return ok, err;
 		end,
 		set_session = meta.set_session;