Skip to content

Commit fc08ec9

Browse files
committed
Fix potential nil pointer dereference when checking container state in Remove
Add nil check for inspected.State before accessing inspected.State.Running in the Remove function. This is consistent with nil checks done elsewhere in the codebase (convergence.go, monitor.go, ps.go) and prevents a potential panic if Docker returns a container without State information.
1 parent e7d870a commit fc08ec9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pkg/compose/remove.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *composeService) Remove(ctx context.Context, projectName string, options
6464
if err != nil {
6565
return err
6666
}
67-
if !inspected.State.Running || (options.Stop && s.dryRun) {
67+
if inspected.State == nil || !inspected.State.Running || (options.Stop && s.dryRun) {
6868
stoppedContainers = append(stoppedContainers, ctr)
6969
}
7070
}

0 commit comments

Comments
 (0)