Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -293,10 +293,12 @@ { if (_fd != -1) close(_fd); _fd = -1; + + [super close]; } - (void)dealloc { if (_fd != -1) Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -253,10 +253,12 @@ - (void)close { [_socket release]; _socket = nil; + + [super close]; } @end @implementation OFHTTPClient @synthesize delegate = _delegate; Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -303,10 +303,12 @@ exception: e]; } [_socket release]; _socket = nil; + + [super close]; } - (int)fileDescriptorForWriting { if (_socket == nil) Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -592,7 +592,9 @@ _process = INVALID_HANDLE_VALUE; _readPipe[0] = NULL; _writePipe[1] = NULL; #endif + + [super close]; } @end Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -175,10 +175,12 @@ { if (_fd != -1) close(_fd); _fd = -1; + + [super close]; } - autorelease { return self; Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -1119,10 +1119,12 @@ - (void)unreadFromBuffer: (const void*)buffer length: (size_t)length; /*! * @brief Closes the stream. + * + * @note If you override this, make sure to call `[super close]`! */ - (void)close; /*! * @brief Performs a lowlevel read. Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -1536,8 +1536,18 @@ _readBufferLength += length; } - (void)close { - OF_UNRECOGNIZED_SELECTOR + [self freeMemory: _readBufferMemory]; + _readBuffer = _readBufferMemory = NULL; + _readBufferLength = 0; + + [self freeMemory: _writeBuffer]; + _writeBuffer = NULL; + _writeBufferLength = 0; + _writeBuffered = false; + + _waitingForDelimiter = false; + _blocking = false; } @end Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -171,10 +171,12 @@ close(_socket); _socket = INVALID_SOCKET; _atEndOfStream = false; + + [super close]; } - (void)dealloc { if (_socket != INVALID_SOCKET) Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -254,17 +254,10 @@ int errNo = 0; if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; - _listening = false; - - /* Make sure to clear the read buffer in case the socket is reused */ - [self freeMemory: _readBuffer]; - _readBuffer = NULL; - _readBufferLength = 0; - if (_SOCKS5Host != nil) { /* Connect to the SOCKS5 proxy instead */ host = _SOCKS5Host; port = _SOCKS5Port; } @@ -664,6 +657,21 @@ errNo: of_socket_errno()]; return v; } #endif + +- (void)close +{ + _listening = false; + + [self freeMemory: _address]; + _address = NULL; + _addressLength = 0; + +#ifdef OF_WII + _port = 0; +#endif + + [super close]; +} @end Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -152,10 +152,12 @@ } - (void)close { _atEndOfStream = true; + + [super close]; } - (void)OF_skip { char buffer[512]; Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -565,7 +565,9 @@ } - (void)close { _closed = true; + + [super close]; } @end