summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-11-12 13:28:46 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-11-12 13:28:46 +0000
commit96ec7898e1acda99dca1c34fbe7a83f1166b2019 (patch)
tree97b1a98db591516ea1638dbe759d034a4c91bbd0 /src
parent44305c4625e254ae756f502c1883c5196cc7949d (diff)
We now have only one string copy for remote topics. We still need two for local though (ick) -- see comments
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5700 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/cmd_topic.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index 6d2f6cf9e..bb6e418bd 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -75,25 +75,36 @@ CmdResult cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
return CMD_FAILURE;
}
}
+
char topic[MAXTOPIC];
- strlcpy(topic,parameters[1],MAXTOPIC-1);
if (IS_LOCAL(user))
{
+ /* XXX: we need two string copies for a local topic, because we cant
+ * let a module see the topic as longer than it actually is
+ */
int MOD_RESULT = 0;
+
+ strlcpy(topic,parameters[1],MAXTOPIC-1);
FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
if (MOD_RESULT)
return CMD_FAILURE;
+
+ strlcpy(Ptr->topic,topic,MAXTOPIC-1);
+ }
+ else
+ {
+ /* Sneaky shortcut, one string copy for a remote topic */
+ strlcpy(Ptr->topic, parameters[1], MAXTOPIC-1);
}
- strlcpy(Ptr->topic,topic,MAXTOPIC-1);
strlcpy(Ptr->setby,user->nick,NICKMAX-1);
Ptr->topicset = ServerInstance->Time();
Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic);
+
if (IS_LOCAL(user))
- {
- FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
- }
+ /* We know 'topic' will contain valid data here */
+ FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user, Ptr, topic));
}
else
{