runtime: fix cleanupSandboxBindMounts panic

Found in UT:
--- FAIL: TestKataCleanupSandbox (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2021-03-23 16:44:47 +08:00
parent 9b689ea1d7
commit b2ec5a43d5

View File

@ -411,7 +411,7 @@ func setupSandboxBindMounts(sandbox *Sandbox) error {
}
func cleanupSandboxBindMounts(sandbox *Sandbox) error {
if len(sandbox.config.SandboxBindMounts) == 0 {
if sandbox.config == nil || len(sandbox.config.SandboxBindMounts) == 0 {
return nil
}