mirror of
https://github.com/prometheus/prometheus.git
synced 2025-07-03 19:13:23 +00:00
fix(model/textparse): Labels(): copy the input to avoid dangling references
Signed-off-by: machine424 <ayoubmrini424@gmail.com>
This commit is contained in:
parent
2bfbd8a714
commit
50a6efd5ec
2 changed files with 6 additions and 2 deletions
|
@ -213,7 +213,9 @@ func (p *OpenMetricsParser) Comment() []byte {
|
|||
|
||||
// Labels writes the labels of the current sample into the passed labels.
|
||||
func (p *OpenMetricsParser) Labels(l *labels.Labels) {
|
||||
s := yoloString(p.series)
|
||||
// Defensive copy in case the following keeps a reference.
|
||||
// See https://github.com/prometheus/prometheus/issues/16490
|
||||
s := string(p.series)
|
||||
|
||||
p.builder.Reset()
|
||||
metricName := unreplace(s[p.offsets[0]-p.start : p.offsets[1]-p.start])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue