Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure hGetBufSome does not cause potentially blocking reads (#5843)

When there is data in a handle buffer, never fetch more than the
available number of elements, since that can cause a blocking read on
Windows.
  • Loading branch information...
commit 370fc0b455f6a03283fbd5c0baa5d08d9115379d 1 parent a360b6b
@pcapriotti pcapriotti authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  GHC/IO/Handle/Text.hs
View
3  GHC/IO/Handle/Text.hs
@@ -889,7 +889,8 @@ hGetBufSome h ptr count
-- that bufReadNBNonEmpty will not
-- issue another read.
else
- bufReadNBNonEmpty h_ buf (castPtr ptr) 0 count
+ let count' = min count (bufferElems buf)
+ in bufReadNBNonEmpty h_ buf (castPtr ptr) 0 count'
haFD :: Handle__ -> FD
haFD h_@Handle__{..} =
Please sign in to comment.
Something went wrong with that request. Please try again.