From ca42a22e209b0f608fb957ed65fcdaacd7865b32 Mon Sep 17 00:00:00 2001 From: Bjoern Rabenstein Date: Fri, 10 Oct 2014 19:16:07 +0200 Subject: [PATCH] Add safety panic to seriesMap.put. Change-Id: I4d4d2e45cc0f908a33eb1ae6e3ee6796adfcbd1e --- storage/local/series.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/local/series.go b/storage/local/series.go index e1cc69947..39f648c26 100644 --- a/storage/local/series.go +++ b/storage/local/series.go @@ -60,11 +60,14 @@ func (sm *seriesMap) get(fp clientmodel.Fingerprint) (s *memorySeries, ok bool) return } -// put adds a mapping to the seriesMap. +// put adds a mapping to the seriesMap. It panics if s == nil. func (sm *seriesMap) put(fp clientmodel.Fingerprint, s *memorySeries) { sm.mtx.Lock() defer sm.mtx.Unlock() + if s == nil { + panic("tried to add nil pointer to seriesMap") + } sm.m[fp] = s }