Fix rare reply mention crash (#4055)

* Fix potential out-of-range access of at when stripping reply mention if
the message contained nothing other than the username

* Update changelog entry
This commit is contained in:
pajlada 2022-10-12 11:59:52 +02:00 committed by GitHub
parent ceecc7ef91
commit 3e020b4891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -2,7 +2,7 @@
## Unversioned ## Unversioned
- Major: Added support for Twitch's Chat Replies. [Wiki Page](https://wiki.chatterino.com/Features/#message-replies) (#3722, #3989, #4041, #4047) - Major: Added support for Twitch's Chat Replies. [Wiki Page](https://wiki.chatterino.com/Features/#message-replies) (#3722, #3989, #4041, #4047, #4055)
- Major: Added multi-channel searching to search dialog via keyboard shortcut. (Ctrl+Shift+F by default) (#3694, #3875) - Major: Added multi-channel searching to search dialog via keyboard shortcut. (Ctrl+Shift+F by default) (#3694, #3875)
- Minor: Added highlights for `Elevated Messages`. (#4016) - Minor: Added highlights for `Elevated Messages`. (#4016)
- Minor: Removed total views from the usercard, as Twitch no longer updates the number. (#3792) - Minor: Removed total views from the usercard, as Twitch no longer updates the number. (#3792)

View file

@ -78,6 +78,13 @@ int stripLeadingReplyMention(const QVariantMap &tags, QString &content)
it != tags.end()) it != tags.end())
{ {
auto displayName = it.value().toString(); auto displayName = it.value().toString();
if (content.length() <= 1 + displayName.length())
{
// The reply contains no content
return 0;
}
if (content.startsWith('@') && if (content.startsWith('@') &&
content.at(1 + displayName.length()) == ' ' && content.at(1 + displayName.length()) == ' ' &&
content.indexOf(displayName, 1) == 1) content.indexOf(displayName, 1) == 1)