Commit 5c925279 authored by simonmar's avatar simonmar
Browse files

[project @ 2004-04-20 09:18:46 by simonmar]

Fix a file descriptor leak in openFile: if openFd fails, then we
weren't closing the newly created descriptor.
parent 73bf3856
...@@ -714,6 +714,9 @@ openFile' filepath mode binary = ...@@ -714,6 +714,9 @@ openFile' filepath mode binary =
(c_open f (fromIntegral oflags) 0o666) (c_open f (fromIntegral oflags) 0o666)
openFd fd Nothing filepath mode binary truncate openFd fd Nothing filepath mode binary truncate
`catchException` \e -> do c_close (fromIntegral fd); throw e
-- NB. don't forget to close the FD if openFd fails, otherwise
-- this FD leaks.
-- ASSERT: if we just created the file, then openFd won't fail -- ASSERT: if we just created the file, then openFd won't fail
-- (so we don't need to worry about removing the newly created file -- (so we don't need to worry about removing the newly created file
-- in the event of an error). -- in the event of an error).
......
Supports Markdown
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