Преглед изворни кода

* Fixed a segfault with 'set +' (#17)
* List functions now only work on variables marked as list variables.


svn: 2233

Bryan Drewery пре 21 година
родитељ
комит
5f86324757
2 измењених фајлова са 8 додато и 2 уклоњено
  1. 2 0
      doc/UPDATES
  2. 6 2
      src/set.c

+ 2 - 0
doc/UPDATES

@@ -27,6 +27,8 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Default binary name is now what you name it, or "wraith" if left in "wraith.OS-ver" format.
 * Increased buffer size in binary config for binname/binpath/homedir
 * Removed '+/-manop' from 'chanset' var and added to ignore list for chanset.
+* Fixed a segfault with 'set +' (#17)
+* List functions now only work on variables marked as list variables.
 
 1.2.3
 

+ 6 - 2
src/set.c

@@ -549,7 +549,7 @@ static int var_add_list(const char *botnick, variable_t *var, const char *elemen
     olddata = var->gdata ? var->gdata : NULL;
 
   /* Append to the olddata if there...*/
-  size_t osiz = strlen(olddata);
+  size_t osiz = olddata ? strlen(olddata) : 0;
 
   if (olddata && osiz) {
     size_t esiz = strlen(element) + 1;		// element + ,
@@ -588,7 +588,7 @@ static int var_rem_list(const char *botnick, variable_t *var, const char *elemen
   if (str_isdigit(element))
     num = atoi(element);
 
-  olddata = olddatap = strdup(olddatacp);
+  olddata = olddatap = strdup(olddatacp) : NULL;
   size_t osiz = strlen(olddata), esiz = strlen(element) + 1, tsiz = osiz - esiz + 1;          // element + ,
 
   data = (char *) calloc(1, tsiz);
@@ -680,6 +680,10 @@ void cmd_set_real(const char *botnick, int idx, char *par)
     return;
   }
 
+  if (list && !(var->flags & VAR_LIST)) {
+    dprintf(idx, "That variable is not a list!\n");
+    return;
+  }
   
   struct userrec *botu = NULL;
   bool ishub = 0;