projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
(from parent 1:
5b526f1
)
Merge pull request #2275 from octo/ff/prometheus
author
Florian Forster
<ff@octo.it>
Fri, 12 May 2017 13:17:13 +0000
(15:17 +0200)
committer
GitHub
<noreply@github.com>
Fri, 12 May 2017 13:17:13 +0000
(15:17 +0200)
write_prometheus plugin: Fix incorrect use of realloc().
src/write_prometheus.c
patch
|
blob
|
history
diff --git
a/src/write_prometheus.c
b/src/write_prometheus.c
index
6b77712
..
de1c389
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--;
+ if (fam->n_metric == 0) {
+ sfree(fam->metric);
+ return 0;
+ }
+
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;