windows: Avoid panic if USB Product name is empty
This commit is contained in:
@@ -347,10 +347,12 @@ func retrievePortDetailsFromDevInfo(device *deviceInfo, details *PortDetails) er
|
|||||||
the result of spdrpFriendlyName is therefore unique and suitable as an alternative string to for a port choice */
|
the result of spdrpFriendlyName is therefore unique and suitable as an alternative string to for a port choice */
|
||||||
n := uint32(0)
|
n := uint32(0)
|
||||||
setupDiGetDeviceRegistryProperty(device.set, &device.data, spdrpFriendlyName /* spdrpDeviceDesc */, nil, nil, 0, &n)
|
setupDiGetDeviceRegistryProperty(device.set, &device.data, spdrpFriendlyName /* spdrpDeviceDesc */, nil, nil, 0, &n)
|
||||||
buff := make([]uint16, n*2)
|
if n > 0 {
|
||||||
buffP := (*byte)(unsafe.Pointer(&buff[0]))
|
buff := make([]uint16, n*2)
|
||||||
if setupDiGetDeviceRegistryProperty(device.set, &device.data, spdrpFriendlyName /* spdrpDeviceDesc */, nil, buffP, n, &n) {
|
buffP := (*byte)(unsafe.Pointer(&buff[0]))
|
||||||
details.Product = syscall.UTF16ToString(buff[:])
|
if setupDiGetDeviceRegistryProperty(device.set, &device.data, spdrpFriendlyName /* spdrpDeviceDesc */, nil, buffP, n, &n) {
|
||||||
|
details.Product = syscall.UTF16ToString(buff[:])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user