mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user