Fix segfault in apply_channel

If a parallel master concurrently applied an update, update may be nil,
and we might raise a segafault.
This commit is contained in:
Justin Santa Barbara 2017-01-18 19:51:21 -05:00
parent d569b04ca5
commit 5e08a7de0c
1 changed files with 7 additions and 4 deletions

View File

@ -175,10 +175,13 @@ func (c *ApplyChannelCmd) Run(args []string) error {
if err != nil {
return fmt.Errorf("error updating %q: %v", needUpdate.Name, err)
}
if update.NewVersion.Version != nil {
fmt.Printf("Updated %q to %d\n", update.Name, *update.NewVersion)
} else {
fmt.Printf("Updated %q\n", update.Name)
// Could have been a concurrent request
if update != nil {
if update.NewVersion.Version != nil {
fmt.Printf("Updated %q to %d\n", update.Name, *update.NewVersion)
} else {
fmt.Printf("Updated %q\n", update.Name)
}
}
}