]> source.dussan.org Git - jgit.git/commitdiff
Do not attempt to read bitmap from invalid pack 13/10913/1
authorShawn Pearce <spearce@spearce.org>
Wed, 6 Mar 2013 20:48:25 +0000 (12:48 -0800)
committerShawn Pearce <spearce@spearce.org>
Wed, 6 Mar 2013 20:48:25 +0000 (12:48 -0800)
If a pack file has been marked invalid due to a prior IOException
accessing its contents, do not offer its bitmap index to callers.
The pack cannot be used so its bitmap should be off limits from
any reader trying to work from a bitmap.

Change-Id: Ia44e46558abdddee560bb184158b1e0af9437eee

org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java

index ed6628596a306370a4049fd3676fdf488aafd7b1..80cced84e82d304f317c290d622d1b27772d1b51 100644 (file)
@@ -277,6 +277,8 @@ public final class DfsPackFile {
        }
 
        PackBitmapIndex getBitmapIndex(DfsReader ctx) throws IOException {
+               if (invalid)
+                       return null;
                DfsBlockCache.Ref<PackBitmapIndex> idxref = bitmapIndex;
                if (idxref != null) {
                        PackBitmapIndex idx = idxref.get();
index 31de381721d3a484185409030580f78c399eca82..cd5de595c062d0f9f9ffb8003e6f99d811709d96 100644 (file)
@@ -1057,6 +1057,8 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
        }
 
        synchronized PackBitmapIndex getBitmapIndex() throws IOException {
+               if (invalid)
+                       return null;
                if (bitmapIdx == null && hasExt(BITMAP_INDEX)) {
                        final PackBitmapIndex idx = PackBitmapIndex.open(
                                        extFile(BITMAP_INDEX), idx(), getReverseIdx());