diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2021-09-21 14:54:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-21 14:54:09 +0300 |
commit | 103d74bbab9faa47a9b2aeb4c604d33b6949c73a (patch) | |
tree | 93d0c2e7cb80b7970a30cf4733d3457ebfebb132 /health | |
parent | f7175f032675cd4524a393d94e3829f605b1eca6 (diff) |
fix coverity (#11535)
Diffstat (limited to 'health')
-rw-r--r-- | health/health_config.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/health/health_config.c b/health/health_config.c index 64a7346433..35234df157 100644 --- a/health/health_config.c +++ b/health/health_config.c @@ -734,7 +734,7 @@ static int health_readfile(const char *filename, void *data) { } else if(hash == hash_os && !strcasecmp(key, HEALTH_OS_KEY)) { char *os_match = value; - alert_cfg->os = strdupz(value); + if (alert_cfg) alert_cfg->os = strdupz(value); SIMPLE_PATTERN *os_pattern = simple_pattern_create(os_match, NULL, SIMPLE_PATTERN_EXACT); if(!simple_pattern_matches(os_pattern, host->os)) { @@ -751,7 +751,7 @@ static int health_readfile(const char *filename, void *data) { } else if(hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) { char *host_match = value; - alert_cfg->host = strdupz(value); + if (alert_cfg) alert_cfg->host = strdupz(value); SIMPLE_PATTERN *host_pattern = simple_pattern_create(host_match, NULL, SIMPLE_PATTERN_EXACT); if(!simple_pattern_matches(host_pattern, host->hostname)) { @@ -1226,17 +1226,18 @@ static int health_readfile(const char *filename, void *data) { //health_add_alarms_loop(host, rc, ignore_this) ; if(ignore_this || !alert_hash_and_store_config(rc->config_hash_id, alert_cfg) || !rrdcalc_add_alarm_from_config(host, rc)) { rrdcalc_free(rc); - alert_config_free(alert_cfg); } } if(rt) { if(ignore_this || !alert_hash_and_store_config(rt->config_hash_id, alert_cfg) || !rrdcalctemplate_add_template_from_config(host, rt)) { rrdcalctemplate_free(rt); - alert_config_free(alert_cfg); } } + if (alert_cfg) + alert_config_free(alert_cfg); + fclose(fp); return 1; } |