[EGIT PATCH 02/26] Protect WorkingTreeIterator's name encoding from weird ByteBuffers
- Date: Mon, 11 Aug 2008 18:07:49 -0700
- From: "Shawn O. Pearce" <spearce@xxxxxxxxxxx>
- Subject: [EGIT PATCH 02/26] Protect WorkingTreeIterator's name encoding from weird ByteBuffers
If a ByteBuffer decides to be cute and give us an array but use
an array offset that isn't zero we cannot use its array as our
own encodedName array. Instead we must create a copy of the array
so we can safely assume where the path starts.
Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
.../spearce/jgit/treewalk/WorkingTreeIterator.java | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index 4ac711b..356222b 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -415,7 +415,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
throws CharacterCodingException {
final ByteBuffer b = enc.encode(CharBuffer.wrap(getName()));
encodedNameLen = b.limit();
- if (b.hasArray())
+ if (b.hasArray() && b.arrayOffset() == 0)
encodedName = b.array();
else
b.get(encodedName = new byte[encodedNameLen]);
--
1.6.0.rc2.22.g71b99
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html