Browse Source

Do not attempt to read bitmap from invalid pack

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
stable-3.0
Shawn Pearce 12 years ago
parent
commit
913cccd5c4
  1. 2
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java

2
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java

@ -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();

2
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java

@ -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());

Loading…
Cancel
Save