diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go index 3f350cec27acc..7c82caafd8ca3 100644 --- a/src/runtime/syscall_windows_test.go +++ b/src/runtime/syscall_windows_test.go @@ -780,6 +780,17 @@ func TestDLLPreloadMitigation(t *testing.T) { t.Skip("skipping test: gcc is missing") } + tmpdir, err := ioutil.TempDir("", "TestDLLPreloadMitigation") + if err != nil { + t.Fatal("TempDir failed: ", err) + } + defer func() { + err := os.RemoveAll(tmpdir) + if err != nil { + t.Error(err) + } + }() + dir0, err := os.Getwd() if err != nil { t.Fatal(err) @@ -794,12 +805,6 @@ uintptr_t cfunc() { SetLastError(123); } ` - tmpdir, err := ioutil.TempDir("", "TestDLLPreloadMitigation") - if err != nil { - t.Fatal("TempDir failed: ", err) - } - defer os.RemoveAll(tmpdir) - srcname := "nojack.c" err = ioutil.WriteFile(filepath.Join(tmpdir, srcname), []byte(src), 0) if err != nil {