Browse Source

Check nil Terminal to avoid panic

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Zhang Wei 9 years ago
parent
commit
7f0d304f37
1 changed files with 3 additions and 0 deletions
  1. 3 0
      container/container.go

+ 3 - 0
container/container.go

@@ -232,6 +232,9 @@ func (container *Container) ExitOnNext() {
 // Resize changes the TTY of the process running inside the container
 // Resize changes the TTY of the process running inside the container
 // to the given height and width. The container must be running.
 // to the given height and width. The container must be running.
 func (container *Container) Resize(h, w int) error {
 func (container *Container) Resize(h, w int) error {
+	if container.Command.ProcessConfig.Terminal == nil {
+		return fmt.Errorf("Container %s does not have a terminal ready", container.ID)
+	}
 	if err := container.Command.ProcessConfig.Terminal.Resize(h, w); err != nil {
 	if err := container.Command.ProcessConfig.Terminal.Resize(h, w); err != nil {
 		return err
 		return err
 	}
 	}