git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH] Fix ObjectLoader.getBytes to really return the created copy

From
Jonas Fonseca <fonseca@diku.dk>
Date
Oct 9, 2008, 22:09 UTC
Message-ID
<20081009220932.GA30350@diku.dk>
In-Reply-To
<20081009214926.GA8203@spearce.org>

The bug was carried over from the original code in PackedObjectLoader by commit 4c49ab5a4ec8555681ceabf17142a15bf90c2c24.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 .../src/org/spearce/jgit/lib/ObjectLoader.java     |    2 +-
 Shawn O. Pearce <spearce@spearce.org> wrote Thu, Oct 09, 2008:
 > I think its already committed to master too.  Can you send a patch
 > along to fix, and point out how stupid I am?
 Yes, I noticed it has already been applied. I am lagging behind a bit.
 Anyway, here is a trivial patch.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
index 87e861f..8d745dd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
@@ -109,7 +109,7 @@ protected void setId(final ObjectId id) {
 		final byte[] data = getCachedBytes();
 		final byte[] copy = new byte[data.length];
 		System.arraycopy(data, 0, copy, 0, data.length);
-		return data;
+		return copy;
 	}
 
 	/**
-- 
1.6.0.2.665.g48ddf


-- 
Jonas Fonseca
Previous: Shawn O. Pearce
Message 11 of 11 in “Support receive.fsckobjects”
  1. 0/5 Support receive.fsckobjectsShawn O. Pearce, Oct 1, 2008
  2. 1/5 Expose RawParseUtils.match to application callersShawn O. Pearce, Oct 1, 2008
  3. 2/5 Fix UnpackedObjectLoader.getBytes to return a copyShawn O. Pearce, Oct 1, 2008
  4. 3/5 Object validation tests for "jgit fsck"Shawn O. Pearce, Oct 1, 2008
  5. 4/5 Expose the critical receive configuration options to JGitShawn O. Pearce, Oct 1, 2008
  6. 5/5 Honor receive.fsckobjects during any fetch connectionShawn O. Pearce, Oct 1, 2008
  7. Robin RosenbergOct 1, 2008
  8. Shawn O. PearceOct 2, 2008
  9. Jonas FonsecaOct 9, 2008
  10. Shawn O. PearceOct 9, 2008
  11. Fix ObjectLoader.getBytes to really return the created copyJonas Fonseca, Oct 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.