UnpackedObject: Fix readSome() when initial read is short

JDK7 changed behavior slightly on some InputStream types, resulting in
the first read being shorter than the count requested.  That caused us
to overwrite the earlier part of the buffer with later data, as the
offset index wasn't updated in the loop.

Fix the loop to increment offset by the number of bytes read in this
iteration, so the next read appends to the buffer rather than doing an
overwrite.

Bug: 338119
Change-Id: I222fb2f993cd9b637b6b8d93daab5777ef7ec7a6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2011-02-25 17:20:14 -08:00
parent 7e1f18c079
commit 03f78fc3bc
1 changed files with 1 additions and 0 deletions

View File

@ -328,6 +328,7 @@ private static int readSome(InputStream in, final byte[] hdr, int off,
if (n < 0)
break;
avail += n;
off += n;
cnt -= n;
}
return avail;