mirror of
https://github.com/go-delve/delve.git
synced 2025-10-30 02:07:58 +08:00
service/debugger: close executable file (#2976)
Close executable file after we open it.
This commit is contained in:
committed by
GitHub
parent
c120db3467
commit
7ab33ac92f
@ -28,16 +28,18 @@ func verifyBinaryFormat(exePath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check that the binary format is what we expect for the host system
|
// check that the binary format is what we expect for the host system
|
||||||
|
var exe interface{ Close() error }
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
_, err = macho.NewFile(f)
|
exe, err = macho.NewFile(f)
|
||||||
case "linux", "freebsd":
|
case "linux", "freebsd":
|
||||||
_, err = elf.NewFile(f)
|
exe, err = elf.NewFile(f)
|
||||||
default:
|
default:
|
||||||
panic("attempting to open file Delve cannot parse")
|
panic("attempting to open file Delve cannot parse")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.ErrNotExecutable
|
return api.ErrNotExecutable
|
||||||
}
|
}
|
||||||
|
exe.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,8 +35,10 @@ func verifyBinaryFormat(exePath string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = pe.NewFile(f); err != nil {
|
exe, err := pe.NewFile(f)
|
||||||
|
if err != nil {
|
||||||
return api.ErrNotExecutable
|
return api.ErrNotExecutable
|
||||||
}
|
}
|
||||||
|
exe.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user