csv plugin: set datadir null when free
authorManuel Luis Sanmartin Rozada <manuel.luis@gmail.com>
Tue, 6 Aug 2013 10:30:52 +0000 (12:30 +0200)
committerFlorian Forster <octo@collectd.org>
Wed, 7 Aug 2013 07:42:01 +0000 (09:42 +0200)
If you define twice DataDir:

    <Plugin csv>
DataDir "/opt/collectd/var/lib/collectd/csv"
DataDir stdout
    </Plugin>

the second time datadir will not be null and
you will get garbage in value_list_to_filename

Signed-off-by: Florian Forster <octo@collectd.org>
src/csv.c

index f123c5d..958e34b 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
@@ -215,7 +215,10 @@ static int csv_config (const char *key, const char *value)
        if (strcasecmp ("DataDir", key) == 0)
        {
                if (datadir != NULL)
+               {
                        free (datadir);
+                       datadir = NULL;
+               }
                if (strcasecmp ("stdout", value) == 0)
                {
                        use_stdio = 1;