Skip to content

Commit 7cf5a6a

Browse files
committed
vz: fix nil pointer dereference with mountType: reverse-sshfs
``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x10075a5a4] goroutine 1 [running]: github.com/Code-Hex/vz/v3/internal/objc.ConvertToNSMutableArray.func1(0x2?, 0x600000c143f0?) /Users/suda/gopath/pkg/mod/github.com/!code-!hex/vz/[email protected]/internal/objc/objc.go:134 +0x24 github.com/Code-Hex/vz/v3/internal/objc.ConvertToNSMutableArray({0xc0002c85c0, 0x2, 0xc0001fdb20?}) /Users/suda/gopath/pkg/mod/github.com/!code-!hex/vz/[email protected]/internal/objc/objc.go:134 +0xef github.com/Code-Hex/vz/v3.(*VirtualMachineConfiguration).SetDirectorySharingDevicesVirtualMachineConfiguration(0xc00012e000?, {0xc0002c85a0, 0x2, 0x1f?}) /Users/suda/gopath/pkg/mod/github.com/!code-!hex/vz/[email protected]/configuration.go:188 +0x77 github.com/lima-vm/lima/pkg/vz.attachFolderMounts(0xc00047e780, 0xb?) /Users/suda/gopath/src/github.com/lima-vm/lima/pkg/vz/vm_darwin.go:381 +0x214 github.com/lima-vm/lima/pkg/vz.createVM(0x1000811e5?, 0xc00012e040?) /Users/suda/gopath/src/github.com/lima-vm/lima/pkg/vz/vm_darwin.go:124 +0xf8 github.com/lima-vm/lima/pkg/vz.startVM({0x100b42d30?, 0xc0000da008}, 0xc00047e780) /Users/suda/gopath/src/github.com/lima-vm/lima/pkg/vz/vm_darwin.go:32 +0x5b github.com/lima-vm/lima/pkg/vz.(*LimaVzDriver).Start(0xc0004b62b0, {0x100b42d30, 0xc0000da008}) /Users/suda/gopath/src/github.com/lima-vm/lima/pkg/vz/vz_driver_darwin.go:106 +0xf3 github.com/lima-vm/lima/pkg/hostagent.(*HostAgent).Run(0xc0000e0480, {0x100b42d30?, 0xc0000da008}) /Users ``` Signed-off-by: Akihiro Suda <[email protected]>
1 parent 45cd9cf commit 7cf5a6a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/vz/vm_darwin.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func attachConsole(_ *driver.BaseDriver, vmConfig *vz.VirtualMachineConfiguratio
335335
}
336336

337337
func attachFolderMounts(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfiguration) error {
338-
mounts := make([]vz.DirectorySharingDeviceConfiguration, len(driver.Yaml.Mounts))
338+
var mounts []vz.DirectorySharingDeviceConfiguration
339339
if *driver.Yaml.MountType == limayaml.VIRTIOFS {
340340
for i, mount := range driver.Yaml.Mounts {
341341
expandedPath, err := localpathutil.Expand(mount.Location)
@@ -364,7 +364,7 @@ func attachFolderMounts(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineCo
364364
return err
365365
}
366366
config.SetDirectoryShare(share)
367-
mounts[i] = config
367+
mounts = append(mounts, config)
368368
}
369369
}
370370

@@ -378,7 +378,9 @@ func attachFolderMounts(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineCo
378378
}
379379
}
380380

381-
vmConfig.SetDirectorySharingDevicesVirtualMachineConfiguration(mounts)
381+
if len(mounts) > 0 {
382+
vmConfig.SetDirectorySharingDevicesVirtualMachineConfiguration(mounts)
383+
}
382384
return nil
383385
}
384386

0 commit comments

Comments
 (0)