From 82c53822ecef034b1b88f47ebaa13b4d8c8ac836 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 18 Apr 2013 03:30:22 +0200 Subject: m_callerid Fix bookkeeping error introduced when unserializing callerid_data This also fixes a memory leak that didn't occur naturally but was triggerable by remote servers Thanks to @SimosNap for the report --- src/modules/m_callerid.cpp | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 7f843f252..812df1da0 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -38,26 +38,6 @@ class callerid_data std::list wholistsme; callerid_data() : lastnotify(0) { } - callerid_data(const std::string& str) - { - irc::commasepstream s(str); - std::string tok; - if (s.GetToken(tok)) - { - lastnotify = ConvToInt(tok); - } - while (s.GetToken(tok)) - { - if (tok.empty()) - { - continue; - } - - User *u = ServerInstance->FindNick(tok); - if ((u) && (u->registered == REG_ALL) && (!u->quitting) && (!IS_SERVER(u))) - accepting.insert(u); - } - } std::string ToString(SerializeFormat format) const { @@ -88,8 +68,29 @@ struct CallerIDExtInfo : public ExtensionItem void unserialize(SerializeFormat format, Extensible* container, const std::string& value) { - callerid_data* dat = new callerid_data(value); - set_raw(container, dat); + callerid_data* dat = new callerid_data; + irc::commasepstream s(value); + std::string tok; + if (s.GetToken(tok)) + dat->lastnotify = ConvToInt(tok); + + while (s.GetToken(tok)) + { + if (tok.empty()) + continue; + + User *u = ServerInstance->FindNick(tok); + if ((u) && (u->registered == REG_ALL) && (!u->quitting) && (!IS_SERVER(u))) + { + callerid_data* other = this->get(u, true); + other->wholistsme.push_back(dat); + dat->accepting.insert(u); + } + } + + void* old = set_raw(container, dat); + if (old) + this->free(old); } callerid_data* get(User* user, bool create) -- cgit v1.2.3