From 3e020b4891ee8b90b9b7f4948a7b9567ad9a7ed9 Mon Sep 17 00:00:00 2001 From: pajlada Date: Wed, 12 Oct 2022 11:59:52 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 2 +- src/providers/twitch/IrcMessageHandler.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1566254f..e28ec862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 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) - Minor: Added highlights for `Elevated Messages`. (#4016) - Minor: Removed total views from the usercard, as Twitch no longer updates the number. (#3792) diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index da32a6a8..af39b3f4 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -78,6 +78,13 @@ int stripLeadingReplyMention(const QVariantMap &tags, QString &content) it != tags.end()) { auto displayName = it.value().toString(); + + if (content.length() <= 1 + displayName.length()) + { + // The reply contains no content + return 0; + } + if (content.startsWith('@') && content.at(1 + displayName.length()) == ' ' && content.indexOf(displayName, 1) == 1)