projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.7'
[collectd.git]
/
src
/
write_prometheus.c
diff --git
a/src/write_prometheus.c
b/src/write_prometheus.c
index
6dee98a
..
14d78bb
100644
(file)
--- a/
src/write_prometheus.c
+++ b/
src/write_prometheus.c
@@
-546,9
+546,14
@@
metric_family_delete_metric(Io__Prometheus__Client__MetricFamily *fam,
((fam->n_metric - 1) - i) * sizeof(fam->metric[i]));
fam->n_metric--;
((fam->n_metric - 1) - i) * sizeof(fam->metric[i]));
fam->n_metric--;
+ if (fam->n_metric == 0) {
+ sfree(fam->metric);
+ return 0;
+ }
+
Io__Prometheus__Client__Metric **tmp =
realloc(fam->metric, fam->n_metric * sizeof(*fam->metric));
Io__Prometheus__Client__Metric **tmp =
realloc(fam->metric, fam->n_metric * sizeof(*fam->metric));
- if (
(tmp != NULL) || (fam->n_metric == 0)
)
+ if (
tmp != NULL
)
fam->metric = tmp;
return 0;
fam->metric = tmp;
return 0;
@@
-694,8
+699,10
@@
metric_family_get(data_set_t const *ds, value_list_t const *vl, size_t ds_index,
return fam;
}
return fam;
}
- if (!allocate)
+ if (!allocate) {
+ sfree(name);
return NULL;
return NULL;
+ }
fam = metric_family_create(name, ds, vl, ds_index);
if (fam == NULL) {
fam = metric_family_create(name, ds, vl, ds_index);
if (fam == NULL) {