From: Aki Tuomi Date: Thu, 19 May 2022 09:39:55 +0000 (+0300) Subject: stats: stats-service-openmetrics - Always clear the stack before next metric body X-Git-Tag: 2.3.20~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b3b959d0cd16692cdb09265aa4758bf5f5ea1ff;p=thirdparty%2Fdovecot%2Fcore.git stats: stats-service-openmetrics - Always clear the stack before next metric body If the attempt of generating output for the previous metric doesn’t completely consume the stack, the next metric will start with a non-empty stack, which breaks the metrics output. --- diff --git a/src/stats/stats-service-openmetrics.c b/src/stats/stats-service-openmetrics.c index 9c50592e2e..c286c67d53 100644 --- a/src/stats/stats-service-openmetrics.c +++ b/src/stats/stats-service-openmetrics.c @@ -595,6 +595,8 @@ openmetrics_export_continue(struct openmetrics_request *req, string_t *out) /* Export the HELP/TYPE header for the current metric */ str_truncate(req->labels, req->labels_pos); req->has_submetric = FALSE; + if (array_is_created(&req->sub_metric_stack)) + array_clear(&req->sub_metric_stack); openmetrics_export_metric_header(req, out); req->state = OPENMETRICS_REQUEST_STATE_SUB_METRICS; break;