diff options
Diffstat (limited to 'crypto/src/util/io/PushbackStream.cs')
-rw-r--r-- | crypto/src/util/io/PushbackStream.cs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/crypto/src/util/io/PushbackStream.cs b/crypto/src/util/io/PushbackStream.cs index d51e195ca..2ceb64361 100644 --- a/crypto/src/util/io/PushbackStream.cs +++ b/crypto/src/util/io/PushbackStream.cs @@ -13,31 +13,33 @@ namespace Org.BouncyCastle.Utilities.IO { } - public override int ReadByte() + public override int Read(byte[] buffer, int offset, int count) { + Streams.ValidateBufferArguments(buffer, offset, count); + if (m_buf != -1) { - int tmp = m_buf; + if (count < 1) + return 0; + + buffer[offset] = (byte)m_buf; m_buf = -1; - return tmp; + return 1; } - return base.ReadByte(); + return base.Read(buffer, offset, count); } - public override int Read(byte[] buffer, int offset, int count) + public override int ReadByte() { - if (count < 1) - return 0; - if (m_buf != -1) { - buffer[offset] = (byte)m_buf; + int tmp = m_buf; m_buf = -1; - return 1; + return tmp; } - return base.Read(buffer, offset, count); + return base.ReadByte(); } public virtual void Unread(int b) |