summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-04-22 21:32:05 +0200
committerBjørn Erik Pedersen <[email protected]>2018-04-22 21:32:05 +0200
commit24c662ce6bea029b0b24160376eaceaed1481d1c (patch)
treebfd357d59cc534428f6cfd45691ba6b7efab9b2f
parent474bad34ca9d3fcb15130530569983ef3ef1a284 (diff)
downloadhugo-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.go3
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) {