summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBelgin Știrbu <belginstirbu@hotmail.com>2022-05-30 20:52:30 -0500
committerBelgin Știrbu <belginstirbu@hotmail.com>2022-05-30 20:52:30 -0500
commit7678368a270a203f2d6fcc3454575508c46e245e (patch)
tree0f553004d91ae503e2b380864d2b420227944638
parent395fecbf53dbf3b9d3861991ad3998c2ab57a0c2 (diff)
downloadpidgin-7678368a270a203f2d6fcc3454575508c46e245e.tar.gz
Fix segmentation fault on IRC server reply
When Pidgin received `:nick!user@host JOIN #channel` from an IRC server, it worked fine, but when it received `:nick JOIN #channel`, it crashed with a segmentation fault. Testing Done: Tested with a custom IRC server that only sends the nickname. Also tested on Libera Chat. Bugs closed: PIDGIN-17375 Reviewed at https://reviews.imfreedom.org/r/1484/
-rw-r--r--libpurple/protocols/irc/msgs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
index c43c062677..219ef666b5 100644
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -71,7 +71,14 @@ static char *irc_mask_nick(const char *mask)
static char *irc_mask_userhost(const char *mask)
{
- return g_strdup(strchr(mask, '!') + 1);
+ char *sep = strchr(mask, '!');
+ char *host = "";
+
+ if(sep) {
+ host = sep + 1;
+ }
+
+ return g_strdup(host);
}
static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2])