csv plugin: plug memory leak on error
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 28 Nov 2015 19:19:26 +0000 (20:19 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 30 Nov 2015 10:50:28 +0000 (11:50 +0100)
CID 38015

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

index 958e34b..5268237 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
@@ -65,13 +65,16 @@ static int value_list_to_string (char *buffer, int buffer_len,
                                && (ds->ds[i].type != DS_TYPE_GAUGE)
                                && (ds->ds[i].type != DS_TYPE_DERIVE)
                                && (ds->ds[i].type != DS_TYPE_ABSOLUTE))
+               {
+                       sfree (rates);
                        return (-1);
+               }
 
-               if (ds->ds[i].type == DS_TYPE_GAUGE) 
+               if (ds->ds[i].type == DS_TYPE_GAUGE)
                {
                        status = ssnprintf (buffer + offset, buffer_len - offset,
                                        ",%lf", vl->values[i].gauge);
-               } 
+               }
                else if (store_rates != 0)
                {
                        if (rates == NULL)