From d12acfb222589b51515e32ac6b1a3152d826bf18 Mon Sep 17 00:00:00 2001 From: KnicKnic Date: Thu, 26 Dec 2019 21:26:47 -0800 Subject: [PATCH] fix localalloc typo --- pkg/powershell/chelpers.go | 6 ++++-- pkg/powershell/zpsh_host.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/powershell/chelpers.go b/pkg/powershell/chelpers.go index f984c17..784417f 100644 --- a/pkg/powershell/chelpers.go +++ b/pkg/powershell/chelpers.go @@ -41,7 +41,7 @@ func mallocCopyArrayGenericPowerShellObject(input []nativePowerShell_GenericPowe inputCount := uint64(len(input)) - var size uint64 + var size uint64 = 0 if inputCount != 0 { size = inputCount * uint64(unsafe.Sizeof(input[0])) } @@ -51,7 +51,9 @@ func mallocCopyArrayGenericPowerShellObject(input []nativePowerShell_GenericPowe panic("Couldn't allocate memory") } - _ = memcpyGenericPowerShellObject(data, &input[0], size) + if inputCount != 0 { + _ = memcpyGenericPowerShellObject(data, &input[0], size) + } return data } diff --git a/pkg/powershell/zpsh_host.go b/pkg/powershell/zpsh_host.go index 9742782..b0f4c88 100644 --- a/pkg/powershell/zpsh_host.go +++ b/pkg/powershell/zpsh_host.go @@ -201,7 +201,7 @@ func nativePowerShell_DefaultAlloc(size uint64) (status uintptr, err error) { return } func localAlloc(size uint64) (status uintptr, err error) { - r0, _, err := syscall.Syscall(procLocalAlloc.Addr(), 1, uintptr(size), 0, 0) + r0, _, err := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(0), uintptr(size), 0) status = uintptr(r0) if status != uintptr(0) { err = nil