Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
CodedInputStream bufferSize is set incorrectly when reading from a byte[] slice
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jack Punt  
View profile  
 More options Oct 9 2012, 3:08 am
From: Jack Punt <thegr...@gmail.com>
Date: Tue, 9 Oct 2012 00:08:18 -0700 (PDT)
Local: Tues, Oct 9 2012 3:08 am
Subject: CodedInputStream bufferSize is set incorrectly when reading from a byte[] slice

The CodedInputStream(byte[], int, int), the setting of: bufferSize = *off+ *
len;
would appear to be an error.  I expect it should be: bufferSize = len;
(generally, bufferSize is the max value of bufferPos in the buffer byte[])

This leads to various confusion and ArrayIndexOutOfBoundsException when
using a byte[] slice.

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[]

Note: There are other inconsistencies (wrt bufferSize & totalBytesRetired)
in refillBuffer, where bufferSize is not what it seems (when using a byte[]
slice)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oliver Jowett  
View profile  
 More options Oct 10 2012, 3:39 am
From: Oliver Jowett <oliver.jow...@gmail.com>
Date: Wed, 10 Oct 2012 08:39:02 +0100
Local: Wed, Oct 10 2012 3:39 am
Subject: Re: [protobuf] CodedInputStream bufferSize is set incorrectly when reading from a byte[] slice

On Tue, Oct 9, 2012 at 8:08 AM, Jack Punt <thegr...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »