shithub: hugo

Download patch

ref: 24c662ce6bea029b0b24160376eaceaed1481d1c
parent: 474bad34ca9d3fcb15130530569983ef3ef1a284
author: Bjørn Erik Pedersen <[email protected]>
date: Sun Apr 22 17:32:05 EDT 2018

hugolib: Defer the unlock in orderedMap.Add

Just in case someone tries to recover from the potential panic.

--- a/hugolib/orderedMap.go
+++ b/hugolib/orderedMap.go
@@ -38,6 +38,7 @@
 
 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))
@@ -44,8 +45,6 @@
 	}
 	m.m[k] = v
 	m.keys = append(m.keys, k)
-	m.Unlock()
-
 }
 
 func (m *orderedMap) Get(k interface{}) (interface{}, bool) {