protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
if (!_finalBlockTransformed)
{
FlushFinalBlock();
}
if (!_leaveOpen)
{
_stream.Dispose();
}
}
}
finally
{
try
{
// Ensure we don't try to transform the final block again if we get disposed twice
// since it's null after this
_finalBlockTransformed = true;
// we need to clear all the internal buffers
if (_inputBuffer != null)
Array.Clear(_inputBuffer, 0, _inputBuffer.Length);
if (_outputBuffer != null)
Array.Clear(_outputBuffer, 0, _outputBuffer.Length);
_inputBuffer = null;
_outputBuffer = null;
_canRead = false;
_canWrite = false;
}
finally
{
base.Dispose(disposing);
}
}
}