diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c index 2c39a77a..e91fc738 100644 --- a/src/irc/core/irc.c +++ b/src/irc/core/irc.c @@ -321,6 +321,8 @@ static int irc_receive_line(SERVER_REC *server, char **str, int read_socket) static char *irc_parse_prefix(char *line, char **nick, char **address) { + char *p; + *nick = *address = NULL; /* : [["!" ] "@" ] SPACE */ @@ -328,18 +330,24 @@ static char *irc_parse_prefix(char *line, char **nick, char **address) if (*line != ':') return line; - *nick = ++line; + *nick = ++line; p = NULL; while (*line != '\0' && *line != ' ') { if (*line == '!' || *line == '@') { - *line++ = '\0'; - *address = line; - while (*line != '\0' && *line != ' ') - line++; - break; + p = line; + if (*line == '!') + break; } line++; } + if (p != NULL) { + line = p; + *line++ = '\0'; + *address = line; + while (*line != '\0' && *line != ' ') + line++; + } + if (*line == ' ') { *line++ = '\0'; while (*line == ' ') line++;