aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-23 19:31:04 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-24 11:23:23 +0200
commit9073a4b28fc5839893981924b61c0b4ae5f96a86 (patch)
tree3d78adc72905659f0c5b6c195afeaad54267d92c
parentmod: bump (diff)
downloadwireguard-windows-9073a4b28fc5839893981924b61c0b4ae5f96a86.tar.xz
wireguard-windows-9073a4b28fc5839893981924b61c0b4ae5f96a86.zip
elevate: do not invoke shell execute if program is empty
-rw-r--r--elevate/shellexecute.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/elevate/shellexecute.go b/elevate/shellexecute.go
index 8e238f08..6290b4f8 100644
--- a/elevate/shellexecute.go
+++ b/elevate/shellexecute.go
@@ -42,7 +42,7 @@ func ShellExecute(program string, arguments string, directory string, show int32
}
defer func() {
- if err != nil {
+ if err != nil && program16 != nil {
err = windows.ShellExecute(0, windows.StringToUTF16Ptr("runas"), program16, arguments16, directory16, show)
}
}()
@@ -132,6 +132,10 @@ func ShellExecute(program string, arguments string, directory string, show int32
defer syscall.Syscall((*interfacePointer)[releaseOffset], 1, uintptr(unsafe.Pointer(interfacePointer)), 0, 0)
+ if program16 == nil {
+ return
+ }
+
if ret, _, _ := syscall.Syscall6((*interfacePointer)[shellExecuteOffset], 6,
uintptr(unsafe.Pointer(interfacePointer)),
uintptr(unsafe.Pointer(program16)),