Skip to content

Commit 43e9f18

Browse files
committed
Fix Go 1.15 checkptr failure; use golang.org/x/sys/windows.UTF16PtrToString
The UTF16PtrToString version in golang.org/x/sys/windows doesn't make slices pointing past the end of an allocation. Use it instead. This lets programs using lxn/win and built with Go's race detector get a bit further. Other race/checkptr issues with lxn/win and lxn/walk remain for subsequent changes. Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 2da648f commit 43e9f18

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

AUTHORS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ Alexander Neumann <[email protected]>
1313
Aman Gupta <[email protected]>
1414
Anton Lahti <[email protected]>
1515
Benny Siegert <[email protected]>
16+
Brad Fitzpatrick <[email protected]>
1617
Bruno Bigras <[email protected]>
1718
Carl Kittelberger <[email protected]>
1819
Carlos Cobo <[email protected]>
1920
Cary Cherng <[email protected]>
21+
Cory Redmond <[email protected]>
2022
David Porter <[email protected]>
23+
Dmitry Bagdanov <[email protected]>
2124
gonutz
2225
2326
Jason A. Donenfeld <[email protected]>
@@ -29,6 +32,3 @@ ryujimiya <[email protected]>
2932
Simon Rozman <[email protected]>
3033
Tiago Carvalho <[email protected]>
3134
32-
gonutz
33-
Cory Redmond <[email protected]>
34-
Dmitry Bagdanov <[email protected]>

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/lxn/win
22

33
go 1.12
44

5-
require golang.org/x/sys v0.0.0-20190904154756-749cb33beabd
5+
require golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13

win.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
package win
88

99
import (
10-
"syscall"
1110
"unsafe"
11+
12+
"golang.org/x/sys/windows"
1213
)
1314

1415
const (
@@ -70,10 +71,7 @@ func HIWORD(dw uint32) uint16 {
7071
}
7172

7273
func UTF16PtrToString(s *uint16) string {
73-
if s == nil {
74-
return ""
75-
}
76-
return syscall.UTF16ToString((*[1 << 29]uint16)(unsafe.Pointer(s))[0:])
74+
return windows.UTF16PtrToString(s)
7775
}
7876

7977
func MAKEINTRESOURCE(id uintptr) *uint16 {

0 commit comments

Comments
 (0)