mirror of
https://github.com/docker/cli.git
synced 2026-01-19 21:41:31 +03:00
return err instead of panic when convert string to utf16
Signed-off-by: Boshi Lian <farmer1992@gmail.com> Upstream-commit: 1c770c6d8c531bf237252eb23e183cad26b7f64a Component: engine
This commit is contained in:
@@ -146,7 +146,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)
|
||||
|
||||
Reference in New Issue
Block a user