about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-03-25 11:54:59 +0100
committerMichael Vetter <jubalh@iodoru.org>2021-03-25 11:54:59 +0100
commite396e863dda53839ba4d00d175999e07d6143369 (patch)
tree1bba88eb2cd625b304147f3910c6db7da57e0eaa
parent9cfe5ec787dabc0a081951b3573a595725113f30 (diff)
downloadprofani-tty-e396e863dda53839ba4d00d175999e07d6143369.tar.gz
message: safeguard _handle_receipt_received
This shouldnt be necessary since we check for the receipt outside
alreayd. Let's be on the safe side though in case code gets changed
later.
-rw-r--r--src/xmpp/message.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 91fd40a3..00d8ec1a 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1131,24 +1131,26 @@ static void
 _handle_receipt_received(xmpp_stanza_t* const stanza)
 {
     xmpp_stanza_t* receipt = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
-    const char* name = xmpp_stanza_get_name(receipt);
-    if (g_strcmp0(name, "received") != 0) {
-        return;
-    }
+    if (receipt) {
+        const char* name = xmpp_stanza_get_name(receipt);
+        if (g_strcmp0(name, "received") != 0) {
+            return;
+        }
 
-    const char* id = xmpp_stanza_get_id(receipt);
-    if (!id) {
-        return;
-    }
+        const char* id = xmpp_stanza_get_id(receipt);
+        if (!id) {
+            return;
+        }
 
-    const char* fulljid = xmpp_stanza_get_from(stanza);
-    if (!fulljid) {
-        return;
-    }
+        const char* fulljid = xmpp_stanza_get_from(stanza);
+        if (!fulljid) {
+            return;
+        }
 
-    Jid* jidp = jid_create(fulljid);
-    sv_ev_message_receipt(jidp->barejid, id);
-    jid_destroy(jidp);
+        Jid* jidp = jid_create(fulljid);
+        sv_ev_message_receipt(jidp->barejid, id);
+        jid_destroy(jidp);
+    }
 }
 
 static void