Handle tags without values

Otherwise a tag with no value would cause a segfault trying to
unescape the NULL tag pointer. This shouldn't happen for the server
tags we parse, but clients could send @+draft/reply with no value.
master
C. McEnroe 2021-08-15 12:24:15 -04:00
parent 3f3585d0f3
commit df1e561378
1 changed files with 6 additions and 2 deletions

8
irc.c
View File

@ -250,8 +250,12 @@ static struct Message parse(char *line) {
char *key = strsep(&tag, "="); char *key = strsep(&tag, "=");
for (uint i = 0; i < TagCap; ++i) { for (uint i = 0; i < TagCap; ++i) {
if (strcmp(key, TagNames[i])) continue; if (strcmp(key, TagNames[i])) continue;
unescape(tag); if (tag) {
msg.tags[i] = tag; unescape(tag);
msg.tags[i] = tag;
} else {
msg.tags[i] = "";
}
break; break;
} }
} }