Commit c2025c41 authored by Hyang-Ah (Hana) Kim's avatar Hyang-Ah (Hana) Kim Committed by Hyang-Ah Hana Kim

os: fix LinkError creation on windows.

Not only carrying invalid info but also this caused Error to crash with
null pointer exception.

Change-Id: Ibfe63d20eb9b9178ea618e59c74111e9245a6779
Reviewed-on: https://go-review.googlesource.com/6270
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 2b417dc3
......@@ -508,9 +508,8 @@ func Link(oldname, newname string) error {
if err != nil {
return &LinkError{"link", oldname, newname, err}
}
e := syscall.CreateHardLink(n, o, 0)
if e != nil {
err = syscall.CreateHardLink(n, o, 0)
if err != nil {
return &LinkError{"link", oldname, newname, err}
}
return nil
......
......@@ -533,6 +533,14 @@ func TestHardLink(t *testing.T) {
if err != nil {
t.Fatalf("link %q, %q failed: %v", to, from, err)
}
none := "hardlinktestnone"
err = Link(none, none)
// Check the returned error is well-formed.
if lerr, ok := err.(*LinkError); !ok || lerr.Error() == "" {
t.Errorf("link %q, %q failed to return a valid error", none, none)
}
defer Remove(from)
tostat, err := Stat(to)
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment