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
2 changed files with 8 additions and 1 deletions
@@ -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)