@@ -97,15 +97,16 @@ hGetContents h = do
9797 return (hh'{haType=ClosedHandle},T.concat ts)
9898 where
9999 readAll hh@Handle__{..} = do
100− buf <- readIORef haCharBuffer
101100 let readChunks = do
102− t <- readChunk hh buf
103− (hh',ts) <- readAll hh
101+ t <- readChunk hh =<< readIORef haCharBuffer
102+ (hh',ts) <- readChunks
104103 return (hh', t:ts)
105104 readChunks `catch` \e -> do
106105 (hh', _) <- hClose_help hh
107106 if isEOFError e
108− then return $ if isEmptyBuffer buf
107+ then do
108+ buf <- readIORef haCharBuffer
109+ return $ if isEmptyBuffer buf
109110 then (hh', [])
110111 else (hh', [T.singleton '\r'])
111112 else throw (augmentIOError e "hGetContents" h)