Commit b84bd95b authored by Mahmood Ali's avatar Mahmood Ali
Browse files

don't lock if ref is nil

Ensure that d.mu is only dereferenced if d is not-nil, to avoid a null
dereference panic.
parent d787c28d
Showing with 4 additions and 3 deletions
+4 -3
......@@ -117,12 +117,13 @@ func NewAllocDir(logger hclog.Logger, allocDir string) *AllocDir {
// Copy an AllocDir and all of its TaskDirs. Returns nil if AllocDir is
// nil.
func (d *AllocDir) Copy() *AllocDir {
d.mu.RLock()
defer d.mu.RUnlock()
if d == nil {
return nil
}
d.mu.RLock()
defer d.mu.RUnlock()
dcopy := &AllocDir{
AllocDir: d.AllocDir,
SharedDir: d.SharedDir,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment