mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +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
|
||||
var exe interface{ Close() error }
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
_, err = macho.NewFile(f)
|
||||
exe, err = macho.NewFile(f)
|
||||
case "linux", "freebsd":
|
||||
_, err = elf.NewFile(f)
|
||||
exe, err = elf.NewFile(f)
|
||||
default:
|
||||
panic("attempting to open file Delve cannot parse")
|
||||
}
|
||||
if err != nil {
|
||||
return api.ErrNotExecutable
|
||||
}
|
||||
exe.Close()
|
||||
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
|
||||
}
|
||||
exe.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user