Skip to content

Commit

Permalink
* Fix #116.
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed Jul 11, 2024
1 parent 53951a0 commit 54b8973
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/discord/FormattedText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void FormattedText::UseRegex(std::string& str)
// Not too expensive I hope!
if (flags & HAS_BSLASH)
{
for (size_t i = 0; i < str.size() - 1; i++) {
for (size_t i = 0; !str.empty() && i < str.size() - 1; i++) {
if (str[i] != '\\')
continue;

Expand All @@ -733,15 +733,15 @@ void FormattedText::UseRegex(std::string& str)
}
if (flags & HAS_QUOTE)
{
for (size_t i = 0; i < str.size() - 2; i++) {
for (size_t i = 0; str.size() > 2 && i < str.size() - 2; i++) {

if ((i == 0 || str[i - 1] == '\n') && str[i] == '>' && str[i + 1] == ' ')
str[i] = CHAR_BEG_QUOTE, str[i + 1] = CHAR_NOOP;
}
}
if (flags & HAS_AT)
{
for (size_t i = 0; i < str.size() - 2; i++) {
for (size_t i = 0; str.size() > 2 && i < str.size() - 2; i++) {
if (str[i] != '@')
continue;

Expand Down

0 comments on commit 54b8973

Please sign in to comment.