Resolve coverity issues (#12846)

- Variable "hostname" going out of scope leaks the storage it points to.
- Null-checking "rd->name" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
This commit is contained in:
Stelios Fragkakis 2022-05-09 10:47:58 +03:00 committed by GitHub
parent 6072d04055
commit 0b3ee50c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -38,7 +38,7 @@ inline RRDDIM *rrddim_find(RRDSET *st, const char *id) {
// RRDDIM rename a dimension
inline int rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name) {
if(unlikely(!name || !*name || !strcmp(rd->name, name)))
if(unlikely(!name || !*name || (rd->name && !strcmp(rd->name, name))))
return 0;
debug(D_RRD_CALLS, "rrddim_set_name() from %s.%s to %s.%s", st->name, rd->name, st->name, name);

View File

@ -353,6 +353,7 @@ void aclk_send_chart_event(struct aclk_database_worker_config *wc, struct aclk_d
if (rc != SQLITE_OK) {
error_report("Failed to prepare statement when trying to send a chart update via ACLK");
freez(claim_id);
freez(hostname);
return;
}
}
@ -774,7 +775,6 @@ void aclk_start_streaming(char *node_id, uint64_t sequence_id, time_t created_at
freez(chart_reset.claim_id);
wc->chart_reset_count = -1;
}
return;
} else {
struct aclk_database_cmd cmd;
memset(&cmd, 0, sizeof(cmd));
@ -797,12 +797,11 @@ void aclk_start_streaming(char *node_id, uint64_t sequence_id, time_t created_at
wc->chart_updates = 1;
}
}
freez(hostname);
} else {
hostname = get_hostname_by_node_id(node_id);
log_access("ACLK STA [%s (%s)]: ACLK synchronization thread is not active.", node_id, hostname ? hostname : "N/A");
freez(hostname);
}
freez(hostname);
return;
}
host = host->next;