Code

postgresql plugin: Remove invalid free().
authorFlorian Forster <octo@collectd.org>
Tue, 8 Dec 2015 10:49:56 +0000 (11:49 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 8 Dec 2015 10:49:56 +0000 (11:49 +0100)
CID: 37936

src/postgresql.c

index e613662ae1510893cd6df91ae6652c503e1e238f..78f6fe574c2428f523532dde74b911547d58696f 100644 (file)
@@ -1161,7 +1161,7 @@ static int c_psql_config_writer (oconfig_item_t *ci)
 
        writers = tmp;
        writer  = writers + writers_num;
-       ++writers_num;
+       memset (writer, 0, sizeof (*writer));
 
        writer->name = sstrdup (ci->values[0].value.string);
        writer->statement = NULL;
@@ -1181,10 +1181,10 @@ static int c_psql_config_writer (oconfig_item_t *ci)
        if (status != 0) {
                sfree (writer->statement);
                sfree (writer->name);
-               sfree (writer);
                return status;
        }
 
+       ++writers_num;
        return 0;
 } /* c_psql_config_writer */