From: bep Date: Fri, 20 Feb 2015 16:41:37 +0000 (+0100) Subject: Avoid race condition in isInnerShortcode X-Git-Tag: v0.13~4 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c33a8528f864b71f046e0325121a809580d85531;p=brevno-suite%2Fhugo Avoid race condition in isInnerShortcode As reported by Go's race detector. See #917 --- diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index 0bdfcd5a..41560c0f 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 }