Fix integer overflow on windows

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2020-09-28 18:38:57 +00:00
parent cc3785c815
commit bd7c6ca6fa

View File

@ -347,8 +347,8 @@ func initPanicFile(path string) error {
// Update STD_ERROR_HANDLE to point to the panic file so that Go writes to // Update STD_ERROR_HANDLE to point to the panic file so that Go writes to
// it when it panics. Remember the old stderr to restore it before removing // it when it panics. Remember the old stderr to restore it before removing
// the panic file. // the panic file.
sh := windows.STD_ERROR_HANDLE sh := uint32(windows.STD_ERROR_HANDLE)
h, err := windows.GetStdHandle(uint32(sh)) h, err := windows.GetStdHandle(sh)
if err != nil { if err != nil {
return err return err
} }
@ -372,7 +372,7 @@ func initPanicFile(path string) error {
func removePanicFile() { func removePanicFile() {
if st, err := panicFile.Stat(); err == nil { if st, err := panicFile.Stat(); err == nil {
if st.Size() == 0 { if st.Size() == 0 {
sh := windows.STD_ERROR_HANDLE sh := uint32(windows.STD_ERROR_HANDLE)
setStdHandle.Call(uintptr(sh), uintptr(oldStderr)) setStdHandle.Call(uintptr(sh), uintptr(oldStderr))
panicFile.Close() panicFile.Close()
os.Remove(panicFile.Name()) os.Remove(panicFile.Name())