@cryptotaxi247 / netdata-1 / commits / 0b3ee50c7

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.

Stelios Fragkakis committed May 9, 2022 at 10:47 UTC 0b3ee50c76dcc3b8dcdd13cec0e432394d3c6964
2 files changed +3 -4
database/rrddim.c
+1 -1
@@ -38,7 +38,7 @@ inline RRDDIM *rrddim_find(RRDSET *st, const char *id) {
38 // RRDDIM rename a dimension
39
40 inline int rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name) {
41 - if(unlikely(!name || !*name || !strcmp(rd->name, name)))
41 + if(unlikely(!name || !*name || (rd->name && !strcmp(rd->name, name))))
42 return 0;
43
44 debug(D_RRD_CALLS, "rrddim_set_name() from %s.%s to %s.%s", st->name, rd->name, st->name, name);
database/sqlite/sqlite_aclk_chart.c
+2 -3
@@ -353,6 +353,7 @@ void aclk_send_chart_event(struct aclk_database_worker_config *wc, struct aclk_d
353 if (rc != SQLITE_OK) {
354 error_report("Failed to prepare statement when trying to send a chart update via ACLK");
355 freez(claim_id);
356 + freez(hostname);
357 return;
358 }
359 }
@@ -774,7 +775,6 @@ void aclk_start_streaming(char *node_id, uint64_t sequence_id, time_t created_at
775 freez(chart_reset.claim_id);
776 wc->chart_reset_count = -1;
777 }
777 - return;
778 } else {
779 struct aclk_database_cmd cmd;
780 memset(&cmd, 0, sizeof(cmd));
@@ -797,12 +797,11 @@ void aclk_start_streaming(char *node_id, uint64_t sequence_id, time_t created_at
797 wc->chart_updates = 1;
798 }
799 }
800 - freez(hostname);
800 } else {
801 hostname = get_hostname_by_node_id(node_id);
802 log_access("ACLK STA [%s (%s)]: ACLK synchronization thread is not active.", node_id, hostname ? hostname : "N/A");
804 - freez(hostname);
803 }
804 + freez(hostname);
805 return;
806 }
807 host = host->next;