diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-04-22 21:32:05 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-04-22 21:32:05 +0200 |
commit | 24c662ce6bea029b0b24160376eaceaed1481d1c (patch) | |
tree | bfd357d59cc534428f6cfd45691ba6b7efab9b2f | |
parent | 474bad34ca9d3fcb15130530569983ef3ef1a284 (diff) | |
download | hugo-24c662ce6bea029b0b24160376eaceaed1481d1c.tar.gz hugo-24c662ce6bea029b0b24160376eaceaed1481d1c.zip |
hugolib: Defer the unlock in orderedMap.Add
Just in case someone tries to recover from the potential panic.
-rw-r--r-- | hugolib/orderedMap.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/hugolib/orderedMap.go b/hugolib/orderedMap.go index c8879baa7..457cd3d6e 100644 --- a/hugolib/orderedMap.go +++ b/hugolib/orderedMap.go @@ -38,14 +38,13 @@ func newOrderedMapFromStringMapString(m map[string]string) *orderedMap { func (m *orderedMap) Add(k, v interface{}) { m.Lock() + defer m.Unlock() _, found := m.m[k] if found { panic(fmt.Sprintf("%v already added", v)) } m.m[k] = v m.keys = append(m.keys, k) - m.Unlock() - } func (m *orderedMap) Get(k interface{}) (interface{}, bool) { |