From: Florian Forster Date: Mon, 4 Dec 2017 07:18:33 +0000 (+0100) Subject: table plugin: Add explicit NULL checks to clear functions. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6d63f6e9834c838e0a6469d9eaf17feffa3b2959;p=collectd.git table plugin: Add explicit NULL checks to clear functions. CID: 37966 --- diff --git a/src/table.c b/src/table.c index 082914a3..eb18660c 100644 --- a/src/table.c +++ b/src/table.c @@ -77,6 +77,10 @@ static void tbl_result_setup(tbl_result_t *res) { } /* tbl_result_setup */ static void tbl_result_clear(tbl_result_t *res) { + if (res == NULL) { + return; + } + sfree(res->type); sfree(res->instance_prefix); @@ -101,10 +105,16 @@ static void tbl_setup(tbl_t *tbl, char *file) { } /* tbl_setup */ static void tbl_clear(tbl_t *tbl) { + if (tbl == NULL) { + return; + } + sfree(tbl->file); sfree(tbl->sep); sfree(tbl->instance); + /* (tbl->results == NULL) -> (tbl->results_num == 0) */ + assert((tbl->results != NULL) || (tbl->results_num == 0)); for (size_t i = 0; i < tbl->results_num; ++i) tbl_result_clear(tbl->results + i); sfree(tbl->results);