diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-03-10 03:33:39 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-03-10 03:33:39 -0500 |
commit | 35473b3bafbc9f25f3ecd29d1aa18b14ec420390 (patch) | |
tree | b9aeaff7e016934afb91e54f9110698366c03e56 /components | |
parent | 1538e56052f607c0d3942a3613edcf735daef13c (diff) | |
download | abaddon-portaudio-35473b3bafbc9f25f3ecd29d1aa18b14ec420390.tar.gz abaddon-portaudio-35473b3bafbc9f25f3ecd29d1aa18b14ec420390.zip |
fix some memory safety things (thanks ASan)
Diffstat (limited to 'components')
-rw-r--r-- | components/chatmessage.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index f9d96ee..3682636 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -714,8 +714,6 @@ void ChatMessageItemContainer::HandleEmojis(Gtk::TextView &tv) { void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf) { static auto rgx = Glib::Regex::create(R"(<a?:([\w\d_]+):(\d+)>)"); - auto &img = Abaddon::Get().GetImageManager(); - auto text = GetText(buf); Glib::MatchInfo match; @@ -724,6 +722,8 @@ void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf) int mstart, mend; if (!match.fetch_pos(0, mstart, mend)) break; + const auto new_term = ":" + match.fetch(1) + ":"; + const auto chars_start = g_utf8_pointer_to_offset(text.c_str(), text.c_str() + mstart); const auto chars_end = g_utf8_pointer_to_offset(text.c_str(), text.c_str() + mend); auto start_it = buf->get_iter_at_offset(chars_start); @@ -736,7 +736,7 @@ void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf) const int blen = text.size(); startpos -= (alen - blen); - buf->insert(it, ":" + match.fetch(1) + ":"); + buf->insert(it, new_term); text = GetText(buf); } |