Skip to content

Commit

Permalink
internal/glfwwin: bug fix: crash when dropping a file
Browse files Browse the repository at this point in the history
Updates #2478
  • Loading branch information
hajimehoshi committed Dec 2, 2022
1 parent 15c2fe0 commit 6a0eb82
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/glfwwin/api_windows.go
Expand Up @@ -1063,7 +1063,11 @@ func _DragFinish(hDrop _HDROP) {
}

func _DragQueryFileW(hDrop _HDROP, iFile uint32, file []uint16) uint32 {
r, _, _ := procDragQueryFileW.Call(uintptr(hDrop), uintptr(iFile), uintptr(unsafe.Pointer(&file[0])), uintptr(len(file)))
var filePtr unsafe.Pointer
if len(file) > 0 {
filePtr = unsafe.Pointer(&file[0])
}
r, _, _ := procDragQueryFileW.Call(uintptr(hDrop), uintptr(iFile), uintptr(filePtr), uintptr(len(file)))
return uint32(r)
}

Expand Down Expand Up @@ -1493,7 +1497,11 @@ func _RegisterDeviceNotificationW(hRecipient windows.Handle, notificationFilter
}

func _RegisterRawInputDevices(pRawInputDevices []_RAWINPUTDEVICE) error {
r, _, e := procRegisterRawInputDevices.Call(uintptr(unsafe.Pointer(&pRawInputDevices[0])), uintptr(len(pRawInputDevices)), unsafe.Sizeof(pRawInputDevices[0]))
var rawInputDevices unsafe.Pointer
if len(pRawInputDevices) > 0 {
rawInputDevices = unsafe.Pointer(&pRawInputDevices[0])
}
r, _, e := procRegisterRawInputDevices.Call(uintptr(rawInputDevices), uintptr(len(pRawInputDevices)), unsafe.Sizeof(_RAWINPUTDEVICE{}))
if int32(r) == 0 {
return fmt.Errorf("glfwwin: RegisterRawInputDevices failed: %w", e)
}
Expand Down

0 comments on commit 6a0eb82

Please sign in to comment.