tokio-xmpp: do not discard XmlLangStack when boxing the stream

Jonas Schäfer created

The stream may have read some data already (such as the stream
header). When initially writing this code, I had missed that we do
actually also carry the parser state over: I misread the
AsyncReader::wrap(..) command as something like AsyncReader::new, i.e.
starting off with fresh parser state, so I assumed that we need a fresh
XmlLangStack, too.

This is wrong: `p` comes from `self.parser.into_inner()` above and is
the parser state, so we need to carry the lang stack along, as well.

This fixes:

```
thread 'tokio-runtime-worker' panicked at […]/rxml-0.13.1/src/xml_lang.rs:87:13:
pop from empty XmlLangStack
```

happening during stream shutdown. The panic was first reported by
@ppjet6, so thanks for that and the keen eye.

skip-changelog, because the bug has not been released yet.

Change summary

tokio-xmpp/src/xmlstream/common.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Detailed changes

tokio-xmpp/src/xmlstream/common.rs 🔗

@@ -300,7 +300,7 @@ impl<Io: AsyncBufRead + AsyncWrite> RawXmlStream<Io> {
         let parser = rxml::AsyncReader::wrap(io, p);
         RawXmlStream {
             parser,
-            lang_stack: XmlLangStack::new(),
+            lang_stack: self.lang_stack,
             timeouts: self.timeouts,
             writer: self.writer,
             tx_buffer: self.tx_buffer,