Fixed #1416 (false negative resource leak when calling fdopen)