From 6c63b53cf4870bc1303b1a2df835d5b67a9b88c4 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 15 Jan 2023 00:52:34 +0100 Subject: [PATCH] fix: Fix crash with direct server IQs --- packages/moxxmpp/lib/src/connection.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/moxxmpp/lib/src/connection.dart b/packages/moxxmpp/lib/src/connection.dart index 22a6ed8..99bed7d 100644 --- a/packages/moxxmpp/lib/src/connection.dart +++ b/packages/moxxmpp/lib/src/connection.dart @@ -523,7 +523,10 @@ class XmppConnection { var future = Future.value(XMLNode(tag: 'not-used')); if (awaitable) { future = await _stanzaAwaiter.addPending( - data.stanza.to!, + // A stanza with no to attribute is for direct processing by the server. As such, + // we can correlate it by just *assuming* we have that attribute + // (RFC 6120 Section 8.1.1.1) + data.stanza.to ?? _connectionSettings.jid.toBare().toString(), data.stanza.id!, data.stanza.tag, );