From 73c410a3a0086957ab2c330879634fdd24c05ded Mon Sep 17 00:00:00 2001 From: Yaroslav Vorobiov Date: Tue, 5 May 2020 14:48:15 +0300 Subject: [PATCH] windows: UTF16PtrToString explicitly return empty string for a ptr to NULL terminator --- windows/syscall_windows.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 907ce21f..12c0544c 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -126,6 +126,10 @@ func UTF16PtrToString(p *uint16) string { if p == nil { return "" } + if *p == 0 { + return "" + } + // Find NUL terminator. n := 0 for ptr := unsafe.Pointer(p); *(*uint16)(ptr) != 0; n++ {