Skip to content

Commit

Permalink
Avoid race condition in isInnerShortcode
Browse files Browse the repository at this point in the history
As reported by Go's race detector.

See #917
  • Loading branch information
bep committed Feb 20, 2015
1 parent a389268 commit c33a852
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hugolib/shortcode.go
Expand Up @@ -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
}
Expand Down

0 comments on commit c33a852

Please sign in to comment.