From 61950817fa56c1cfeb5f8043c2f0975d2f8a1e90 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 4 Mar 2018 22:18:14 +0900 Subject: [PATCH] audio: Bug fix: importing audio without NewContext causes error --- audio/audio.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/audio/audio.go b/audio/audio.go index 80af9b338..ef3629bb2 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -167,9 +167,14 @@ var ( func init() { hooks.AppendHookOnUpdate(func() error { - theContext.m.Lock() - err := theContext.err - theContext.m.Unlock() + var err error + theContextLock.Lock() + if theContext != nil { + theContext.m.Lock() + err = theContext.err + theContext.m.Unlock() + } + theContextLock.Unlock() return err }) }