Commit e6c8e5d3 authored by Simon Marlow's avatar Simon Marlow

hGetBuf: fix a case of a short read being returned (#4427)

parent a75383cd
...@@ -861,7 +861,7 @@ bufReadEmpty h_@Handle__{..} ...@@ -861,7 +861,7 @@ bufReadEmpty h_@Handle__{..}
bufReadNonEmpty h_ buf' ptr so_far count bufReadNonEmpty h_ buf' ptr so_far count
where where
loop :: FD -> Int -> Int -> IO Int loop :: FD -> Int -> Int -> IO Int
loop fd off bytes | bytes <= 0 = return off loop fd off bytes | bytes <= 0 = return (so_far + off)
loop fd off bytes = do loop fd off bytes = do
r <- RawIO.read (fd::FD) (ptr `plusPtr` off) (fromIntegral bytes) r <- RawIO.read (fd::FD) (ptr `plusPtr` off) (fromIntegral bytes)
if r == 0 if r == 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment