Skip to content

Commit

Permalink
check for NULL handle in _fd (#39879)
Browse files Browse the repository at this point in the history
In this case the object is in an invalid state, but it at least allows
printing the object so you can see that.
  • Loading branch information
JeffBezanson authored Mar 2, 2021
1 parent 49387b2 commit 05e6650
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ _fd(x::Union{OS_HANDLE, RawFD}) = x

function _fd(x::Union{LibuvStream, LibuvServer})
fd = Ref{OS_HANDLE}(INVALID_OS_HANDLE)
if x.status != StatusUninit && x.status != StatusClosed
if x.status != StatusUninit && x.status != StatusClosed && x.handle != C_NULL
err = ccall(:uv_fileno, Int32, (Ptr{Cvoid}, Ptr{OS_HANDLE}), x.handle, fd)
# handle errors by returning INVALID_OS_HANDLE
end
Expand Down

0 comments on commit 05e6650

Please sign in to comment.