Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -244,10 +244,11 @@ case BLOCK_HEADER: if OF_UNLIKELY (_inLastBlock) { [_stream unreadFromBuffer: _buffer + _bufferIndex length: _bufferLength - _bufferIndex]; + _bufferIndex = _bufferLength = 0; _atEndOfStream = true; return bytesWritten; } @@ -675,11 +676,16 @@ } #endif - (void)close { + /* Give back our buffer to the stream, in case it's shared */ + [_stream unreadFromBuffer: _buffer + _bufferIndex + length: _bufferLength - _bufferIndex]; + _bufferIndex = _bufferLength = 0; + [_stream release]; _stream = nil; [super close]; } @end Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -690,10 +690,15 @@ _bufferLength - _bufferIndex == 0 && _state == STATE_BLOCK_HEADER); } - (void)close { + /* Give back our buffer to the stream, in case it's shared */ + [_stream unreadFromBuffer: _buffer + _bufferIndex + length: _bufferLength - _bufferIndex]; + _bufferIndex = _bufferLength = 0; + [_stream release]; _stream = nil; [super close]; }