Re: [protobuf] CodedInputStream bufferSize is set incorrectly when reading from a byte[] slice

87 views
Skip to first unread message

Oliver Jowett

unread,
Oct 10, 2012, 3:39:02 AM10/10/12
to Jack Punt, prot...@googlegroups.com
On Tue, Oct 9, 2012 at 8:08 AM, Jack Punt <theg...@gmail.com> wrote:

> For example: CodedInputStream.newInstance("AAAAA".getBytes(), 5,5).isAtEnd()
> --> false [when obviously the buffer is 'empty' at this point]
> and readBytes() will likewise expect to find more bytes than are actually in
> the byte[]

The convention elsewhere is generally that the second (length)
parameter is a count, not an end index - so your example claims that
bytes 5-9 (inclusive) should be used (and you should be providing an
array of length >= 10). See e.g. the ByteArrayInputStream ctor.

Oliver
Reply all
Reply to author
Forward
0 new messages