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

* Fix a segfault in the settings handling code. (Could create very random looking segfaults)


svn: 3932
Bryan Drewery пре 17 година
родитељ
комит
051e40d13c
2 измењених фајлова са 6 додато и 4 уклоњено
  1. 1 0
      doc/UPDATES
  2. 5 4
      src/set.c

+ 1 - 0
doc/UPDATES

@@ -53,6 +53,7 @@
 * Fix datadir being expanded to full path (fixes #405)
 * Bots can now be started as ./binary bot.conf instead of ./binary bot. (Disable autocron and manually crontab it to start like this)
 * Fix a very rare segfault when closing the identd socket (fixes #410)
+* Fix a segfault in the settings handling code. (Could create very random looking segfaults)
 
 1.2.14 - http://wraith.botpack.net/milestone/1.2.14
 * Fix another bug in shell functions. (fixes #321)

+ 5 - 4
src/set.c

@@ -112,7 +112,8 @@ static variable_t vars[] = {
  VAR("servers",		&serverlist,		VAR_SERVERS|VAR_LIST|VAR_SHUFFLE|VAR_NOLHUB|VAR_NOLDEF,	0, 0, DEFAULT_SERVERS),
  VAR("servers6",	&serverlist,		VAR_SERVERS|VAR_LIST|VAR_SHUFFLE|VAR_NOLHUB|VAR_NOLDEF,	0, 0, DEFAULT_SERVERS6),
  VAR("trace",		&trace,			VAR_INT|VAR_DETECTED,				0, 4, "die"),
- VAR("usermode",	&usermode,		VAR_STRING|VAR_NOLHUB,				0, 0, "+iws")
+ VAR("usermode",	&usermode,		VAR_STRING|VAR_NOLHUB,				0, 0, "+iws"),
+ VAR(NULL,		NULL,			0,						0, 0, NULL)
 };
 
 
@@ -758,7 +759,7 @@ static char *var_rem_list(const char *botnick, variable_t *var, const char *elem
   if (!element)
     return ret;
 
-  char *data = NULL, *olddata = NULL, *botdata = NULL, *olddatap = NULL, *olddatacp = NULL, *word = NULL;
+  char *olddata = NULL, *botdata = NULL, *olddatap = NULL, *olddatacp = NULL;
 
   if (botnick) {                          //fetch data from bot's USERENTRY_SET
     botdata = (char *) var_get_bot_data(get_user_by_handle(userlist, (char *) botnick), var->name);
@@ -781,8 +782,8 @@ static char *var_rem_list(const char *botnick, variable_t *var, const char *elem
   olddata = olddatap = strdup(olddatacp);
   size_t tsiz = strlen(olddata) + 1;
 
-  data = (char *) my_calloc(1, tsiz);
-
+  char *data = (char *) my_calloc(1, tsiz);
+  char *word = NULL;
   while ((word = strsep(&olddata, delim))) {
     ++i;