From: Josef 'Jeff' Sipek Date: Mon, 19 Oct 2020 17:47:10 +0000 (-0400) Subject: stats: openmetrics - Include submetric name only when present X-Git-Tag: 2.3.14.rc1~340 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfe9533c2e38be5c65d1fc4076de40eb78ec7450;p=thirdparty%2Fdovecot%2Fcore.git stats: openmetrics - Include submetric name only when present Otherwise we SIGSEGV. --- diff --git a/src/stats/stats-service-openmetrics.c b/src/stats/stats-service-openmetrics.c index a380b0bc73..6b312eb4ae 100644 --- a/src/stats/stats-service-openmetrics.c +++ b/src/stats/stats-service-openmetrics.c @@ -290,9 +290,13 @@ static void openmetrics_export_submetric(struct openmetrics_request *req, string_t *out, const struct metric *metric, int64_t timestamp) { - str_append_c(req->labels, '"'); - json_append_escaped(req->labels, metric->sub_name); - str_append_c(req->labels, '"'); + /* This metric may be a submetric and therefore have a label + associated with it. */ + if (metric->sub_name != NULL) { + str_append_c(req->labels, '"'); + json_append_escaped(req->labels, metric->sub_name); + str_append_c(req->labels, '"'); + } if (req->metric_type == OPENMETRICS_METRIC_TYPE_HISTOGRAM) { if (metric->group_by == NULL ||