summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-18 03:30:22 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-18 03:30:22 +0200
commit82c53822ecef034b1b88f47ebaa13b4d8c8ac836 (patch)
treef823e4333cb45e3ecf4eaefc769cd383ed064c6d
parent47332d6e9b990498dd35457090dd8983d8aae8d3 (diff)
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
-rw-r--r--src/modules/m_callerid.cpp45
1 files changed, 23 insertions, 22 deletions
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<callerid_data *> 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)