Merge branch 'master' into collectd-4
[collectd.git] / src / rrdtool.c
index 814b3e3..52557c0 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/rrdtool.c
- * Copyright (C) 2006  Florian octo Forster
+ * Copyright (C) 2006,2007  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -772,9 +772,14 @@ static int rrd_config (const char *key, const char *value)
                char *saveptr = NULL;
                char *dummy;
                char *ptr;
+               char *value_copy;
                int *tmp_alloc;
 
-               dummy = value;
+               value_copy = strdup (value);
+               if (value_copy == NULL)
+                       return (1);
+
+               dummy = value_copy;
                while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL)
                {
                        dummy = NULL;
@@ -784,6 +789,7 @@ static int rrd_config (const char *key, const char *value)
                        if (tmp_alloc == NULL)
                        {
                                fprintf (stderr, "rrdtool: realloc failed.\n");
+                               free (value_copy);
                                return (1);
                        }
                        rra_timespans_custom = tmp_alloc;
@@ -791,7 +797,7 @@ static int rrd_config (const char *key, const char *value)
                        if (rra_timespans_custom[rra_timespans_custom_num] != 0)
                                rra_timespans_custom_num++;
                } /* while (strtok_r) */
-
+               free (value_copy);
        }
        else if (strcasecmp ("XFF", key) == 0)
        {
@@ -864,7 +870,7 @@ static int rrd_init (void)
        return (0);
 } /* int rrd_init */
 
-void module_register (modreg_e load)
+void module_register (void)
 {
        plugin_register_config ("rrdtool", rrd_config,
                        config_keys, config_keys_num);