@@ -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