History

9gc: fix socket leak

Sigrid Solveig Haflínudóttir committed 4 years ago

Commit 961ec701 parent d93d3851 file · +4 −5Browse files

Unified · Split

9gc.c+4−5
@@ -146,11 +146,10 @@ dial(char *s) · 145 unmodified lines
146146 for (a = r; a != NULL; a = a->ai_next) {
147147 if ((f = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) < 0)
148148 continue;
149− if (connect(f, a->ai_addr, a->ai_addrlen) != 0) {
150− close(f);
151− f = -1;
152− continue;
153− }
149+ if (connect(f, a->ai_addr, a->ai_addrlen) == 0)
150+ break;
151+ close(f);
152+ f = -1;
154153 }
155154 freeaddrinfo(r);
156155

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t