about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/otr/otrlibv3.c12
-rw-r--r--src/otr/otrlibv4.c4
-rw-r--r--src/ui/chatwin.c9
-rw-r--r--src/ui/ui.h2
-rw-r--r--tests/unittests/ui/stub_ui.c2
5 files changed, 17 insertions, 12 deletions
diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c
index b12abbff..05083dea 100644
--- a/src/otr/otrlibv3.c
+++ b/src/otr/otrlibv3.c
@@ -177,11 +177,13 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
         } else {
             context->smstate->nextExpected = OTRL_SMP_EXPECT1;
             if (context->smstate->received_question == 0) {
+                ProfChatWin *chatwin = wins_get_chat(context->username);
                 if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
-                    ui_smp_successful(context->username);
+                    if (chatwin) {
+                        ui_smp_successful(chatwin);
+                    }
                     ui_trust(context->username);
                 } else {
-                    ProfChatWin *chatwin = wins_get_chat(context->username);
                     if (chatwin) {
                         ui_smp_unsuccessful_sender(chatwin);
                     }
@@ -202,11 +204,13 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
             otrl_message_abort_smp(user_state, ops, NULL, context);
         } else {
             context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+            ProfChatWin *chatwin = wins_get_chat(context->username);
             if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) {
-                ui_smp_successful(context->username);
+                if (chatwin) {
+                    ui_smp_successful(chatwin);
+                }
                 ui_trust(context->username);
             } else {
-                ProfChatWin *chatwin = wins_get_chat(context->username);
                 if (chatwin) {
                     ui_smp_unsuccessful_receiver(chatwin);
                 }
diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c
index 089585fb..29d6d57a 100644
--- a/src/otr/otrlibv4.c
+++ b/src/otr/otrlibv4.c
@@ -196,7 +196,9 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
 
         case OTRL_SMPEVENT_SUCCESS:
             if (context->smstate->received_question == 0) {
-                ui_smp_successful(context->username);
+                if (chatwin) {
+                    ui_smp_successful(chatwin);
+                }
                 ui_trust(context->username);
             } else {
                 ui_smp_answer_success(context->username);
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index a5b2a9be..5c8dbca6 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -148,12 +148,11 @@ ui_smp_aborted(ProfChatWin *chatwin)
 }
 
 void
-ui_smp_successful(const char *const barejid)
+ui_smp_successful(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication successful.");
-    }
+    assert(chatwin != NULL);
+
+    win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication successful.");
 }
 
 void
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 11b0f9c6..d497ea00 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -69,7 +69,7 @@ void ui_untrust(const char *const barejid);
 void ui_smp_recipient_initiated(ProfChatWin *chatwin);
 void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question);
 
-void ui_smp_successful(const char *const barejid);
+void ui_smp_successful(ProfChatWin *chatwin);
 void ui_smp_unsuccessful_sender(ProfChatWin *chatwin);
 void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin);
 void ui_smp_aborted(ProfChatWin *chatwin);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index f2b7b01e..77c8dd17 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -73,7 +73,7 @@ void ui_untrust(const char * const barejid) {}
 void ui_smp_recipient_initiated(ProfChatWin *chatwin) {}
 void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question) {}
 
-void ui_smp_successful(const char * const barejid) {}
+void ui_smp_successful(ProfChatWin *chatwin) {}
 void ui_smp_unsuccessful_sender(ProfChatWin *chatwin) {}
 void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin) {}
 void ui_smp_aborted(ProfChatWin *chatwin) {}