Skip to content

Commit

Permalink
Merge pull request moby#30136 from tg123/master
Browse files Browse the repository at this point in the history
Windows: return err instead of panic when convert string to utf16
  • Loading branch information
LK4D4 authored Feb 6, 2017
2 parents dc15fe8 + 1c770c6 commit d387533
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion daemon/logger/etwlogs/etwlogs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ func callEventRegister() error {
}

func callEventWriteString(message string) error {
ret, _, _ := procEventWriteString.Call(uintptr(providerHandle), 0, 0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(message))))
utf16message, err := syscall.UTF16FromString(message)

if err != nil {
return err
}

ret, _, _ := procEventWriteString.Call(uintptr(providerHandle), 0, 0, uintptr(unsafe.Pointer(&utf16message[0])))
if ret != win32CallSuccess {
errorMessage := fmt.Sprintf("ETWLogs provider failed to log message. Error: %d", ret)
logrus.Error(errorMessage)
Expand Down

0 comments on commit d387533

Please sign in to comment.