diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java index e8a125d57..b8d7f3719 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java @@ -169,14 +169,14 @@ public void copyTo(OutputStream out) throws MissingObjectException, final long sz = in.getSize(); byte[] tmp = new byte[1024]; long copied = 0; - for (;;) { + while (copied < sz) { int n = in.read(tmp); if (n < 0) - break; + throw new EOFException(); out.write(tmp, 0, n); copied += n; } - if (copied != sz) + if (0 <= in.read()) throw new EOFException(); } finally { in.close();