Skip to content

Commit 8aa46a3

Browse files
quagsirusbradfitz
authored andcommitted
util/clientmetric: fix regression causing Metric.v to be uninitialised
m.v was uninitialised when Tailscale built with ts_omit_logtail Fixes tailscale#17918 Signed-off-by: Avery Palmer <[email protected]>
1 parent 8444659 commit 8aa46a3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

util/clientmetric/clientmetric.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ func (m *Metric) Publish() {
133133
metrics[m.name] = m
134134
sortedDirty = true
135135

136+
if m.f == nil {
137+
if len(valFreeList) == 0 {
138+
valFreeList = make([]int64, 256)
139+
}
140+
m.v = &valFreeList[0]
141+
valFreeList = valFreeList[1:]
142+
}
143+
136144
if buildfeatures.HasLogTail {
137145
if m.f != nil {
138146
lastLogVal = append(lastLogVal, scanEntry{f: m.f})
139147
} else {
140-
if len(valFreeList) == 0 {
141-
valFreeList = make([]int64, 256)
142-
}
143-
m.v = &valFreeList[0]
144-
valFreeList = valFreeList[1:]
145148
lastLogVal = append(lastLogVal, scanEntry{v: m.v})
146149
}
147150
}

0 commit comments

Comments
 (0)