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 <redacted>
---
.../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