summaryrefslogtreecommitdiffstats
path: root/hugolib/shortcode.go
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-02-20 17:41:37 +0100
committerbep <bjorn.erik.pedersen@gmail.com>2015-02-20 17:41:37 +0100
commitc33a8528f864b71f046e0325121a809580d85531 (patch)
tree0475dff072d3b91fc5627f33b3d6b3e2096a2de3 /hugolib/shortcode.go
parenta3892685bc33b7518894ea21ae2d8a7c9f29e735 (diff)
Avoid race condition in isInnerShortcode
As reported by Go's race detector. See #917
Diffstat (limited to 'hugolib/shortcode.go')
-rw-r--r--hugolib/shortcode.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go
index 0bdfcd5a5..41560c0f4 100644
--- a/hugolib/shortcode.go
+++ b/hugolib/shortcode.go
@@ -160,11 +160,10 @@ func isInnerShortcode(t *template.Template) bool {
return m
}
- match, _ := regexp.MatchString("{{.*?\\.Inner.*?}}", t.Tree.Root.String())
-
isInnerShortcodeCache.Lock()
+ defer isInnerShortcodeCache.Unlock()
+ match, _ := regexp.MatchString("{{.*?\\.Inner.*?}}", t.Tree.Root.String())
isInnerShortcodeCache.m[t.Name()] = match
- isInnerShortcodeCache.Unlock()
return match
}