Unsafe rules.

This commit is contained in:
Nuno Cruces 2021-09-15 13:54:35 +01:00
parent a899c69072
commit e03e9df189
3 changed files with 6 additions and 9 deletions

View File

@ -3,7 +3,6 @@ package zenity
import (
"path/filepath"
"reflect"
"runtime"
"syscall"
"unicode/utf16"
"unsafe"
@ -315,9 +314,8 @@ func browseForFolder(opts options) (string, []string, error) {
args.Title = syscall.StringToUTF16Ptr(*opts.title)
}
if opts.filename != "" {
args.LParam = strptr(opts.filename)
args.LParam = syscall.StringToUTF16Ptr(opts.filename)
args.CallbackFunc = syscall.NewCallback(browseForFolderCallback)
defer runtime.KeepAlive(opts.filename)
}
if opts.ctx != nil {
@ -420,7 +418,7 @@ type _BROWSEINFO struct {
Title *uint16
Flags uint32
CallbackFunc uintptr
LParam uintptr
LParam *uint16
Image int32
}

View File

@ -2,7 +2,6 @@ package zenity
import (
"context"
"runtime"
"syscall"
"unsafe"
)
@ -53,13 +52,12 @@ func message(kind messageKind, text string, opts options) error {
defer unhook()
}
var title uintptr
var title *uint16
if opts.title != nil {
title = strptr(*opts.title)
defer runtime.KeepAlive(*opts.title)
title = syscall.StringToUTF16Ptr(*opts.title)
}
s, _, err := messageBox.Call(0, strptr(text), title, flags)
s, _, err := messageBox.Call(0, strptr(text), uintptr(unsafe.Pointer(title)), flags)
if opts.ctx != nil && opts.ctx.Err() != nil {
return opts.ctx.Err()

View File

@ -525,6 +525,7 @@ func uuid(s string) uintptr {
type _COMObject struct{}
//go:uintptrescapes
func (o *_COMObject) Call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
switch nargs := uintptr(len(a)); nargs {
case 0: