Remove double free in opserv_add_bad_word(), fixing SF#2579877.
[srvx.git] / src / opserv.c
index 689b72adec17f51f9769e83a1e8fa7d1737253fe..8e1efcc531e5712f98906b69485f3741a9f7c09c 100644 (file)
@@ -1815,7 +1815,7 @@ opserv_part_channel(void *data)
 
 static int alert_check_user(const char *key, void *data, void *extra);
 
-static int
+static void
 opserv_new_user_check(struct userNode *user)
 {
     struct opserv_hostinfo *ohi;
@@ -1824,11 +1824,11 @@ opserv_new_user_check(struct userNode *user)
 
     /* Check to see if we should ignore them entirely. */
     if (IsLocal(user) || IsService(user))
-        return 0;
+        return;
 
     /* Check for alerts, and stop if we find one that kills them. */
     if (dict_foreach(opserv_user_alerts, alert_check_user, user))
-        return 1;
+        return;
 
     /* Gag them if appropriate. */
     for (gag = gagList; gag; gag = gag->next) {
@@ -1877,8 +1877,6 @@ opserv_new_user_check(struct userNode *user)
             gline_add(opserv->nick, target, opserv_conf.clone_gline_duration, "AUTO Excessive connections from a single host.", now, now, 1);
         }
     }
-
-    return 0;
 }
 
 static void
@@ -1982,7 +1980,7 @@ opserv_join_check(struct modeNode *mNode)
 
     dict_foreach(opserv_channel_alerts, alert_check_user, user);
 
-    if (channel->bad_channel) {
+    if (opserv && channel->bad_channel) {
         opserv_debug("Found $b%s$b in bad-word channel $b%s$b; removing the user.", user->nick, channel->name);
         if (channel->name[0] != '#')
             DelUser(user, opserv, 1, "OSMSG_ILLEGAL_KILL_REASON");
@@ -2051,7 +2049,6 @@ opserv_add_bad_word(struct svccmd *cmd, struct userNode *user, const char *new_b
                     reply("OSMSG_BAD_NUKING", orig_bad);
                 string_list_delete(opserv_bad_words, bad_idx);
                 bad_idx--;
-                free(orig_bad);
             }
             return 1;
         }