aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-02-25 17:20:14 -0800
committerShawn O. Pearce <spearce@spearce.org>2011-02-25 17:20:14 -0800
commit03f78fc3bc0c60e589c98d56830ffa5ba1eacd7e (patch)
treec5c4fc5d2516f4fb208c72165e3c8389e4b1580a
parent7e1f18c07990cfbb97e621bbfb25d80752add00c (diff)
downloadjgit-03f78fc3bc0c60e589c98d56830ffa5ba1eacd7e.tar.gz
jgit-03f78fc3bc0c60e589c98d56830ffa5ba1eacd7e.zip
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>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObject.java1
1 files changed, 1 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObject.java
index 4065019dc5..b04a294b63 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObject.java
@@ -328,6 +328,7 @@ public class UnpackedObject {
if (n < 0)
break;
avail += n;
+ off += n;
cnt -= n;
}
return avail;