Skip to content

Commit 89964a3

Browse files
committed
fix: race in GetAllCTIndexes()
1 parent 087d22d commit 89964a3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

internal/certificatetransparency/logmetrics.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,14 @@ func (m *LogMetrics) GetAllCTIndexes() CTCertIndex {
138138
m.mutex.RLock()
139139
defer m.mutex.RUnlock()
140140

141-
return m.index
141+
// make a copy of the index and return it
142+
// since map is a refrence type
143+
copyOfIndex := make(map[string]int64)
144+
for k, v := range m.index {
145+
copyOfIndex[k] = v
146+
}
147+
148+
return copyOfIndex
142149
}
143150

144151
func (m *LogMetrics) GetCTIndex(url string) int64 {

0 commit comments

Comments
 (0)