From 7a8b37691f3c2fa3af29b93a42a74e0c507cde2b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 11 Dec 2008 18:46:14 -0800 Subject: [PATCH] Always use the FileHeader buffer during Patch.parseHunks This ensures that if the code is ever refactored in the future to permit different entry path into parseHunks that we won't read the wrong buffer and potentially setup an invalid FileHeader. Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java b/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java index ec40920f..aeb30e95 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java +++ b/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java @@ -202,7 +202,7 @@ public class Patch { return skipFile(buf, startOffset); ptr = fh.parseGitHeaders(ptr); - ptr = parseHunks(fh, buf, ptr); + ptr = parseHunks(fh, ptr); fh.endOffset = ptr; addFile(fh); return ptr; @@ -224,7 +224,7 @@ public class Patch { private int parseTraditionalPatch(final byte[] buf, final int startOffset) { final FileHeader fh = new FileHeader(buf, startOffset); int ptr = fh.parseTraditionalHeaders(startOffset); - ptr = parseHunks(fh, buf, ptr); + ptr = parseHunks(fh, ptr); fh.endOffset = ptr; addFile(fh); return ptr; @@ -237,7 +237,8 @@ public class Patch { return ptr; } - private int parseHunks(final FileHeader fh, final byte[] buf, int c) { + private int parseHunks(final FileHeader fh, int c) { + final byte[] buf = fh.buf; final int sz = buf.length; while (c < sz) { // If we see a file header at this point, we have all of the -- 2.11.4.GIT