diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-10-30 02:48:26 +0200 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-10-30 02:48:26 +0200 |
commit | e661a0773351cd8416f47bd44a62485462c1b17b (patch) | |
tree | 92cb0584278556a43df00817f6cbeeaa1593effa /src/gnunet_chat_lib.c | |
parent | 31060c1502ce34ebed3ceb0b8365ff58169d4db9 (diff) | |
download | libgnunetchat-e661a0773351cd8416f47bd44a62485462c1b17b.tar.gz libgnunetchat-e661a0773351cd8416f47bd44a62485462c1b17b.zip |
Fixed access violations with empty context of internal messages
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r-- | src/gnunet_chat_lib.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index fb86885..e002b89 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -718,7 +718,7 @@ GNUNET_CHAT_message_get_timestamp (const struct GNUNET_CHAT_Message *message) | |||
718 | const struct GNUNET_CHAT_Contact* | 718 | const struct GNUNET_CHAT_Contact* |
719 | GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message) | 719 | GNUNET_CHAT_message_get_sender (const struct GNUNET_CHAT_Message *message) |
720 | { | 720 | { |
721 | if (!message) | 721 | if ((!message) || (!(message->context))) |
722 | return NULL; | 722 | return NULL; |
723 | 723 | ||
724 | const struct GNUNET_MESSENGER_Contact *sender = GNUNET_MESSENGER_get_sender( | 724 | const struct GNUNET_MESSENGER_Contact *sender = GNUNET_MESSENGER_get_sender( |
@@ -768,12 +768,7 @@ GNUNET_CHAT_message_get_read_receipt (const struct GNUNET_CHAT_Message *message, | |||
768 | GNUNET_CHAT_MessageReadReceiptCallback callback, | 768 | GNUNET_CHAT_MessageReadReceiptCallback callback, |
769 | void *cls) | 769 | void *cls) |
770 | { | 770 | { |
771 | if ((!message) || (!(message->msg))) | 771 | if ((!message) || (!(message->msg)) || (!(message->context))) |
772 | return GNUNET_SYSERR; | ||
773 | |||
774 | struct GNUNET_CHAT_Context *context = message->context; | ||
775 | |||
776 | if (!context) | ||
777 | return GNUNET_SYSERR; | 772 | return GNUNET_SYSERR; |
778 | 773 | ||
779 | struct GNUNET_CHAT_MessageIterateReadReceipts it; | 774 | struct GNUNET_CHAT_MessageIterateReadReceipts it; |
@@ -782,7 +777,7 @@ GNUNET_CHAT_message_get_read_receipt (const struct GNUNET_CHAT_Message *message, | |||
782 | it.cls = cls; | 777 | it.cls = cls; |
783 | 778 | ||
784 | return GNUNET_MESSENGER_iterate_members( | 779 | return GNUNET_MESSENGER_iterate_members( |
785 | context->room, it_message_iterate_read_receipts, &it | 780 | message->context->room, it_message_iterate_read_receipts, &it |
786 | ); | 781 | ); |
787 | } | 782 | } |
788 | 783 | ||
@@ -805,7 +800,7 @@ GNUNET_CHAT_message_get_text (const struct GNUNET_CHAT_Message *message) | |||
805 | struct GNUNET_CHAT_File* | 800 | struct GNUNET_CHAT_File* |
806 | GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message) | 801 | GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message) |
807 | { | 802 | { |
808 | if ((!message) || (!(message->msg))) | 803 | if ((!message) || (!(message->msg)) || (!(message->context))) |
809 | return NULL; | 804 | return NULL; |
810 | 805 | ||
811 | if (GNUNET_MESSENGER_KIND_FILE != message->msg->header.kind) | 806 | if (GNUNET_MESSENGER_KIND_FILE != message->msg->header.kind) |
@@ -821,7 +816,7 @@ GNUNET_CHAT_message_get_file (const struct GNUNET_CHAT_Message *message) | |||
821 | struct GNUNET_CHAT_Invitation* | 816 | struct GNUNET_CHAT_Invitation* |
822 | GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message) | 817 | GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message) |
823 | { | 818 | { |
824 | if ((!message) || (!(message->msg))) | 819 | if ((!message) || (!(message->msg)) || (!(message->context))) |
825 | return NULL; | 820 | return NULL; |
826 | 821 | ||
827 | if (GNUNET_MESSENGER_KIND_INVITE != message->msg->header.kind) | 822 | if (GNUNET_MESSENGER_KIND_INVITE != message->msg->header.kind) |
@@ -838,7 +833,7 @@ int | |||
838 | GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message, | 833 | GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message, |
839 | struct GNUNET_TIME_Relative delay) | 834 | struct GNUNET_TIME_Relative delay) |
840 | { | 835 | { |
841 | if ((!message) || (!(message->msg))) | 836 | if ((!message) || (!(message->msg)) || (!(message->context))) |
842 | return GNUNET_SYSERR; | 837 | return GNUNET_SYSERR; |
843 | 838 | ||
844 | struct GNUNET_MESSENGER_Message msg; | 839 | struct GNUNET_MESSENGER_Message msg; |