diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-04-13 23:28:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-04-13 23:28:22 -0700 |
commit | 155390d6bbd514fe318b2fafc64f75762a73fab3 (patch) | |
tree | 6557129665f0ed6649c6d19cdd697c7b7f94fdf3 | |
parent | 645d4177d40c96dd6177bf9bfcbcd78890f03d0f (diff) | |
download | txr-155390d6bbd514fe318b2fafc64f75762a73fab3.tar.gz txr-155390d6bbd514fe318b2fafc64f75762a73fab3.tar.bz2 txr-155390d6bbd514fe318b2fafc64f75762a73fab3.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.
-rw-r--r-- | socket.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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; |