Browse code

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>

Michael Crosby authored on 2016/08/27 02:02:10
Showing 1 changed files
... ...
@@ -147,7 +147,9 @@ func (daemon *Daemon) filterByNameIDMatches(ctx *listContext) []*container.Conta
147 147
 
148 148
 	cntrs := make([]*container.Container, 0, len(matches))
149 149
 	for id := range matches {
150
-		cntrs = append(cntrs, daemon.containers.Get(id))
150
+		if c := daemon.containers.Get(id); c != nil {
151
+			cntrs = append(cntrs, c)
152
+		}
151 153
 	}
152 154
 
153 155
 	// Restore sort-order after filtering