Skip to content

Commit 889ce9b

Browse files
cljordjohanmon
authored andcommitted
Add check_open(sock) to _sockname (JuliaLang#41000)
Not checking could lead to a segfault on closed TCPSockets in getpeername Fixes JuliaLang#40993
1 parent 61eda0d commit 889ce9b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/Sockets/src/Sockets.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ socket is connected to. Valid only for connected TCP sockets.
806806
getpeername(sock::TCPSocket) = _sockname(sock, false)
807807

808808
function _sockname(sock, self=true)
809+
sock.status == StatusInit || check_open(sock)
809810
rport = Ref{Cushort}(0)
810811
raddress = zeros(UInt8, 16)
811812
rfamily = Ref{Cuint}(0)

0 commit comments

Comments
 (0)