Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nil check before setting timeout on docker client #4303

Merged
merged 1 commit into from
May 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ func (d *DockerDriver) newDockerClient(timeout time.Duration) (*docker.Client, e
}
}

if timeout != 0 {
if timeout != 0 && newClient != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the err be set in this case? Otherwise if newClient is nil and the error is nil, it seems like the caller is susceptible to a NPE too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the error is always set if newClient is nil. I read through the methods that return a new dockerClient in

and it always returns an error if the client is nil.

newClient.SetTimeout(timeout)
}
return newClient, merr.ErrorOrNil()
Expand Down