builder/virtualbox: return if cancelled, to avoid nil deref

This commit is contained in:
Mitchell Hashimoto 2013-06-27 22:24:53 -04:00
parent 9a318ceddc
commit 13bff7e353

View File

@ -260,6 +260,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
return nil, rawErr.(error) return nil, rawErr.(error)
} }
// If we were interrupted or cancelled, then just exit.
if _, ok := state[multistep.StateCancelled]; ok {
return nil, errors.New("Build was cancelled.")
}
if _, ok := state[multistep.StateHalted]; ok {
return nil, errors.New("Build was halted.")
}
// Compile the artifact list // Compile the artifact list
files := make([]string, 0, 5) files := make([]string, 0, 5)
visit := func(path string, info os.FileInfo, err error) error { visit := func(path string, info os.FileInfo, err error) error {