Browse Source

Don't leak memory >:o

jesopo 3 years ago
parent
commit
b51b3a4627
1 changed files with 4 additions and 3 deletions
  1. 4 3
      u4/m_chansno.c

+ 4 - 3
u4/m_chansno.c

@@ -570,10 +570,11 @@ static int chansno_override_oper(Cmdoverride *ovr, aClient *cptr, aClient *sptr,
 
 // Added by jesopo
 int chansno_hook_tkladd(aClient *cptr, aClient *sptr, aTKline *tkl, int parc, char *parv[]) {
-	char *setby = strdup(tkl->setby);
-	setby = strtok(setby, "!");
+	char setby[NICKLEN + USERLEN + HOSTLEN + 6];
+	strncpy(setby, tkl->setby, sizeof(setby));
+	char *name = strtok(setby, "!");
 
-	aClient *setter = find_client(setby, NULL);
+	aClient *setter = find_client(name, NULL);
 	if(setter == NULL || (!IsMe(setter) && !MyClient(setter)))
 	{
 		 return HOOK_CONTINUE;