mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Check for non-nil container after match
There can be a race between getting the container ids for matches and getting the actual container. This makes sure that we check that the container returned by `Get` is non-nil before adding it to the list of matches. Fixes #25991 Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
1dc87122cc
commit
a020ec4c8b
1 changed files with 3 additions and 1 deletions
|
@ -147,7 +147,9 @@ func (daemon *Daemon) filterByNameIDMatches(ctx *listContext) []*container.Conta
|
|||
|
||||
cntrs := make([]*container.Container, 0, len(matches))
|
||||
for id := range matches {
|
||||
cntrs = append(cntrs, daemon.containers.Get(id))
|
||||
if c := daemon.containers.Get(id); c != nil {
|
||||
cntrs = append(cntrs, c)
|
||||
}
|
||||
}
|
||||
|
||||
// Restore sort-order after filtering
|
||||
|
|
Loading…
Reference in a new issue