forked from OpenGamers/abaddon
fix some memory safety things (thanks ASan)
This commit is contained in:
parent
1538e56052
commit
35473b3baf
@ -714,8 +714,6 @@ void ChatMessageItemContainer::HandleEmojis(Gtk::TextView &tv) {
|
|||||||
void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf) {
|
void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf) {
|
||||||
static auto rgx = Glib::Regex::create(R"(<a?:([\w\d_]+):(\d+)>)");
|
static auto rgx = Glib::Regex::create(R"(<a?:([\w\d_]+):(\d+)>)");
|
||||||
|
|
||||||
auto &img = Abaddon::Get().GetImageManager();
|
|
||||||
|
|
||||||
auto text = GetText(buf);
|
auto text = GetText(buf);
|
||||||
|
|
||||||
Glib::MatchInfo match;
|
Glib::MatchInfo match;
|
||||||
@ -724,6 +722,8 @@ void ChatMessageItemContainer::CleanupEmojis(Glib::RefPtr<Gtk::TextBuffer> buf)
|
|||||||
int mstart, mend;
|
int mstart, mend;
|
||||||
if (!match.fetch_pos(0, mstart, mend)) break;
|
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_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);
|
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);
|
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();
|
const int blen = text.size();
|
||||||
startpos -= (alen - blen);
|
startpos -= (alen - blen);
|
||||||
|
|
||||||
buf->insert(it, ":" + match.fetch(1) + ":");
|
buf->insert(it, new_term);
|
||||||
|
|
||||||
text = GetText(buf);
|
text = GetText(buf);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,8 @@ struct MessageDeleteBulkData {
|
|||||||
|
|
||||||
struct GuildMemberListUpdateMessage {
|
struct GuildMemberListUpdateMessage {
|
||||||
struct Item {
|
struct Item {
|
||||||
|
virtual ~Item() = default;
|
||||||
|
|
||||||
std::string Type;
|
std::string Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -182,6 +182,9 @@ void FileCacheWorkerThread::loop() {
|
|||||||
auto fp = m_curl_file_handles.find(msg->easy_handle);
|
auto fp = m_curl_file_handles.find(msg->easy_handle);
|
||||||
std::fclose(fp->second);
|
std::fclose(fp->second);
|
||||||
|
|
||||||
|
m_handles.erase(msg->easy_handle);
|
||||||
|
m_handle_urls.erase(msg->easy_handle);
|
||||||
|
|
||||||
curl_multi_remove_handle(m_multi_handle, msg->easy_handle);
|
curl_multi_remove_handle(m_multi_handle, msg->easy_handle);
|
||||||
curl_easy_cleanup(msg->easy_handle);
|
curl_easy_cleanup(msg->easy_handle);
|
||||||
|
|
||||||
@ -189,8 +192,6 @@ void FileCacheWorkerThread::loop() {
|
|||||||
auto cb = m_callbacks.at(url);
|
auto cb = m_callbacks.at(url);
|
||||||
m_callbacks.erase(url);
|
m_callbacks.erase(url);
|
||||||
m_paths.erase(url);
|
m_paths.erase(url);
|
||||||
m_handles.erase(msg->easy_handle);
|
|
||||||
m_handle_urls.erase(msg->easy_handle);
|
|
||||||
m_curl_file_handles.erase(fp);
|
m_curl_file_handles.erase(fp);
|
||||||
// chop off the !
|
// chop off the !
|
||||||
auto old = path;
|
auto old = path;
|
||||||
|
Loading…
Reference in New Issue
Block a user