summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-13 23:28:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-13 23:28:22 -0700
commit79c55f9c9e1b5fb52c8c798e47b0d849e728338c (patch)
tree6557129665f0ed6649c6d19cdd697c7b7f94fdf3 /socket.c
parentb95fa78d3bf572b190cb26bfc73a35d28a30d0dd (diff)
downloadtxr-79c55f9c9e1b5fb52c8c798e47b0d849e728338c.tar.gz
txr-79c55f9c9e1b5fb52c8c798e47b0d849e728338c.tar.bz2
txr-79c55f9c9e1b5fb52c8c798e47b0d849e728338c.zip
open-socket-pair: bugfix.
* socket.c (socketpair_wrap): Don't close descriptors unconditionally in unwind case; only if the list to be returned has not been created.
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/socket.c b/socket.c
index 35ef7220..7b695573 100644
--- a/socket.c
+++ b/socket.c
@@ -1047,7 +1047,7 @@ static val socketpair_wrap(val family, val type, val mode_str)
{
val s0 = open_sockfd(num(sv[0]), family, type, mode_str);
- val s1 = open_sockfd(num(sv[1]), family, type, mode_str);
+ val s1 = open_sockfd(num(sv[1]), family, type, mode_str);
sock_mark_connected(s0);
sock_mark_connected(s1);
@@ -1056,10 +1056,12 @@ static val socketpair_wrap(val family, val type, val mode_str)
}
uw_unwind {
- if (sv[0] != -1)
- close(sv[0]);
- if (sv[1] != -1)
- close(sv[1]);
+ if (!out) {
+ if (sv[0] != -1)
+ close(sv[0]);
+ if (sv[1] != -1)
+ close(sv[1]);
+ }
}
uw_catch_end;