Skip to content

Commit

Permalink
Fix Go 1.15 checkptr failure; use golang.org/x/sys/windows.UTF16PtrTo…
Browse files Browse the repository at this point in the history
…String

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 <brad@danga.com>
  • Loading branch information
bradfitz committed Oct 21, 2020
1 parent 2da648f commit 43e9f18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ Alexander Neumann <an2048@googlemail.com>
Aman Gupta <aman@tmm1.net>
Anton Lahti <antonlahti@gmail.com>
Benny Siegert <bsiegert@gmail.com>
Brad Fitzpatrick <bradfitz@tailscale.com>
Bruno Bigras <bigras.bruno@gmail.com>
Carl Kittelberger <icedream@icedream.pw>
Carlos Cobo <toqueteos@gmail.com>
Cary Cherng <ccherng@gmail.com>
Cory Redmond <ace@ac3-servers.eu>
David Porter <david@porter.me>
Dmitry Bagdanov <dimbojob@gmail.com>
gonutz
Hill <zhubicen@gmail.com>
Jason A. Donenfeld <Jason@zx2c4.com>
Expand All @@ -29,6 +32,3 @@ ryujimiya <ryujimiya236@gmail.com>
Simon Rozman <simon@rozman.si>
Tiago Carvalho <sugoiuguu@tfwno.gf>
wsf01 <wf1337@sina.com>
gonutz
Cory Redmond <ace@ac3-servers.eu>
Dmitry Bagdanov <dimbojob@gmail.com>
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/lxn/win

go 1.12

require golang.org/x/sys v0.0.0-20190904154756-749cb33beabd
require golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13
8 changes: 3 additions & 5 deletions win.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
package win

import (
"syscall"
"unsafe"

"golang.org/x/sys/windows"
)

const (
Expand Down Expand Up @@ -70,10 +71,7 @@ func HIWORD(dw uint32) uint16 {
}

func UTF16PtrToString(s *uint16) string {
if s == nil {
return ""
}
return syscall.UTF16ToString((*[1 << 29]uint16)(unsafe.Pointer(s))[0:])
return windows.UTF16PtrToString(s)
}

func MAKEINTRESOURCE(id uintptr) *uint16 {
Expand Down

0 comments on commit 43e9f18

Please sign in to comment.