summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-07-02 15:05:32 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-07-03 10:54:30 -0700
commit412ca65bd57f6ac3e86aba0f01533f0e1a5fd321 (patch)
tree5347448ad98bfbb670b2dbdddab5d168a8a02f32 /org.eclipse.jgit
parente4a480f658c165cb3d4a2ba4ed2ba9b3de4b1bf2 (diff)
downloadjgit-412ca65bd57f6ac3e86aba0f01533f0e1a5fd321.tar.gz
jgit-412ca65bd57f6ac3e86aba0f01533f0e1a5fd321.zip
Avoid unbounded getCachedBytes during parseAny
Since we don't know the type of object we are parsing, we don't know if its a massive blob, or some small commit or annotated tag. Avoid pulling the cached bytes until we have checked the type and decided if we actually need them to continue parsing right now. This way large blobs which won't fit in memory and would throw a LargeObjectException don't abort parsing. Change-Id: Ifb70df5d1c59f616aa20ee88898cb69524541636 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java5
1 files changed, 2 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
index 51de7c4a51..1236ac6485 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
@@ -746,12 +746,11 @@ public class RevWalk implements Iterable<RevCommit> {
RevObject r = objects.get(id);
if (r == null) {
final ObjectLoader ldr = reader.open(id);
- final byte[] data = ldr.getCachedBytes();
final int type = ldr.getType();
switch (type) {
case Constants.OBJ_COMMIT: {
final RevCommit c = createCommit(id);
- c.parseCanonical(this, data);
+ c.parseCanonical(this, ldr.getCachedBytes());
r = c;
break;
}
@@ -767,7 +766,7 @@ public class RevWalk implements Iterable<RevCommit> {
}
case Constants.OBJ_TAG: {
final RevTag t = new RevTag(id);
- t.parseCanonical(this, data);
+ t.parseCanonical(this, ldr.getCachedBytes());
r = t;
break;
}