diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2019-10-26 01:00:16 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-11-15 16:00:48 -0800 |
commit | 1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd (patch) | |
tree | 4aee7f85a70298f94d206d0cbab600eaccdc3365 /org.eclipse.jgit/src | |
parent | 345e2648df3e17bd18d0f4251774d3f8b298f77c (diff) | |
download | jgit-1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd.tar.gz jgit-1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd.zip |
RewriteGenerator: avoid adding null parent
Prevent adding a null parent to a commit's parent array. Doing so
can cause NPEs later on.
Bug: 552160
Change-Id: Ib24b7b9b7b08e0b6f246006b4a4cade7eeb830b9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java index 2e26641ebc..b77407bb38 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java @@ -103,11 +103,15 @@ class RewriteGenerator extends Generator { final int nParents = pList.length; for (int i = 0; i < nParents; i++) { final RevCommit oldp = pList[i]; - if (firstParent && i > 0) { - c.parents = new RevCommit[] { rewrite(oldp) }; + final RevCommit newp = rewrite(oldp); + if (firstParent) { + if (newp == null) { + c.parents = RevCommit.NO_PARENTS; + } else { + c.parents = new RevCommit[] { newp }; + } return c; } - final RevCommit newp = rewrite(oldp); if (oldp != newp) { pList[i] = newp; rewrote = true; |