Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #68: Avoid leaking FD, in case of error #69

Merged
merged 1 commit into from
Dec 17, 2021
Merged

Fix for issue #68: Avoid leaking FD, in case of error #69

merged 1 commit into from
Dec 17, 2021

Conversation

stephan57160
Copy link
Contributor

Almost the same fix than a former fix in termios/pty.go

When xx.Open() succeeds, ensure FD is closed, when an error
is detected with other treatments.

Fix applied in term_open_posix.go and term_solaris.go

@stephan57160 stephan57160 mentioned this pull request Dec 15, 2021
Copy link
Member

@davecheney davecheney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please address the comments then I'll submit, thank you.

@@ -22,13 +22,21 @@ func Open(name string, options ...func(*Term) error) (*Term, error) {

orig, err := termios.Tcgetattr(uintptr(fd))
if err != nil {
_ = unix.Close(fd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to assign the value to _, just write unix.Close(fd)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed on both files and squashed.

Almost the same fix than a former fix in termios/pty.go

When xx.Open() succeeds, ensure FD is closed, when an error
is detected with other treatments.

Fix applied in term_open_posix.go and term_solaris.go
Copy link
Member

@davecheney davecheney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@davecheney davecheney merged commit 1a4a3b7 into pkg:master Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants