hGetContents: close the handle properly on error
authorSimon Marlow <marlowsd@gmail.com>
Wed, 25 Nov 2009 12:34:35 +0000 (12:34 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 25 Nov 2009 12:34:35 +0000 (12:34 +0000)
commit1d714d4281fd400253b7b887f77765a6b87148a0
tree4788718bf025d365531f68bf38c61bf0d21eeb30
parent7bd1a6a2d6ba6acfa19ffe46cb535f0ce427dc86
hGetContents: close the handle properly on error

When hGetContents caught an error it was closing the handle and then
throwing the exception, without updating the handle with the new
closed state.  This lead to a double-closed, which was the cause of

*** glibc detected *** ./Setup: double free or corruption

when iconv_close was called twice on the decoder.

See http://hackage.haskell.org/trac/hackage/ticket/609
GHC/IO/Handle/Text.hs