[JGIT PATCH 3/7] Fix potential NullPointerException in RevWalk.parseTree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If we have previously obtained this RevTree by lookupTree (such as
in a commit) but we are missing in the repository and call parseTree
we want a MissingObjectException to be thrown, not an NPE.  The NPE
tells us nothing and could be the same as a bug internal to RevWalk.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/revwalk/RevWalk.java      |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
index 5a29dcf..0dead10 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
@@ -651,7 +651,10 @@ else if (!(c instanceof RevTree))
 
 		if ((t.flags & PARSED) != 0)
 			return t;
-		if (db.openObject(t).getType() != Constants.OBJ_TREE)
+		final ObjectLoader ldr = db.openObject(t);
+		if (ldr == null)
+			throw new MissingObjectException(t, Constants.TYPE_TREE);
+		if (ldr.getType() != Constants.OBJ_TREE)
 			throw new IncorrectObjectTypeException(t, Constants.TYPE_TREE);
 		t.flags |= PARSED;
 		return t;
-- 
1.6.0.1.319.g9f32b

--
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux