Sfoglia il codice sorgente

* Fixed some similar problems with servers/servers6/nick
* Fixed a memleak in var_set_mem()


svn: 2378

Bryan Drewery 21 anni fa
parent
commit
64aba80c95
2 ha cambiato i file con 18 aggiunte e 11 eliminazioni
  1. 2 0
      doc/UPDATES
  2. 16 11
      src/set.c

+ 2 - 0
doc/UPDATES

@@ -14,6 +14,8 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 1.2.8
 * Fixed [bot]* cmds depending on case of botnicks.
 * Fixed hubs attempting to generate a ctcp version reply after 'cloak-script' was set.
+* Fixed some similar problems with servers/servers6/nick
+* Fixed a memleak in var_set_mem()
 
 1.2.7
 * Forgot 'log_bad = 0;' to fix the '!' showing up for aliases.

+ 16 - 11
src/set.c

@@ -95,12 +95,14 @@ static variable_t vars[] = {
 
 static bool use_server_type(const char *name)
 {
-  if (!strcmp(name, "servers")) {
-    if (conf.bot->net.host6 || conf.bot->net.ip6) /* we want to use the servers6 entry. */
-      return 0;
-  } else if (!strcmp(name, "servers6")) {
-    if (!conf.bot->net.host6 && !conf.bot->net.ip6) /* we probably want to use the normal server list.. */
-      return 0;
+  if (!conf.bot->hub) {
+    if (!strcmp(name, "servers")) {
+      if (conf.bot->net.host6 || conf.bot->net.ip6) /* we want to use the servers6 entry. */
+        return 0;
+    } else if (!strcmp(name, "servers6")) {
+      if (!conf.bot->net.host6 && !conf.bot->net.ip6) /* we probably want to use the normal server list.. */
+        return 0;
+    }
   }
   return 1;
 }
@@ -150,7 +152,7 @@ sdprintf("var (mem): %s -> %s", var->name, datain);
     else if (!isnumber)
       number = 0;
 
-    if (var->flags & VAR_CLOAK) {
+    if (var->flags & VAR_CLOAK && !conf.bot->hub) {
       if (number == 0)
         number = randint(CLOAK_COUNT) + 1;
     }
@@ -168,14 +170,14 @@ sdprintf("var (mem): %s -> %s", var->name, datain);
     } else if (!data) {
       *(bool *) (var->mem) = 0;
     } else
-      return 0;
+      goto end;
   } else if (var->flags & VAR_STRING) {
     if (data)
       strlcpy((char *) var->mem, data, var->size);
     else
       ((char *) var->mem)[0] = 0;
 
-    if (var->flags & VAR_NICK) {
+    if (var->flags & VAR_NICK && !conf.bot->hub) {
        if (!data)
          strlcpy((char *) var->mem, conf.bot->nick, var->size);
        if (server_online && rfc_casecmp(botname, (char *) var->mem))
@@ -195,10 +197,10 @@ sdprintf("var (mem): %s -> %s", var->name, datain);
       (*(rate_t *) (var->mem)).count = 0;
       (*(rate_t *) (var->mem)).time = 0;
     } else
-      return 0;
+      goto end;
   } else if (var->flags & VAR_SERVERS) {
     if (!use_server_type(var->name))
-      return 0;
+      goto end;
 
     if (var->mem && *(struct server_list **)var->mem) {
       clearq(*(struct server_list **) var->mem);
@@ -213,6 +215,9 @@ sdprintf("var (mem): %s -> %s", var->name, datain);
       next_server(&curserv, cursrvname, &curservport, NULL);
     }
   }
+
+  end:
+
   if (datap)
     free(datap);