summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 632cca4)
raw | patch | inline | side by side (parent: 632cca4)
author | Florian Forster <octo@collectd.org> | |
Fri, 12 May 2017 11:05:37 +0000 (13:05 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 12 May 2017 11:06:30 +0000 (13:06 +0200) |
Calling realloc(ptr, 0) is undefined. Call free() explicitly.
src/write_prometheus.c | patch | blob | history |
diff --git a/src/write_prometheus.c b/src/write_prometheus.c
index 6b77712e8ed0ab37b5a09dcb0728bb75f96d0ce6..de1c389c30cc1a2f9ac4318e70d4f0ce5ac79d07 100644 (file)
--- a/src/write_prometheus.c
+++ b/src/write_prometheus.c
((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;