aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/idxfile/idxfile.go
diff options
context:
space:
mode:
authorMiguel Molina <miguel@erizocosmi.co>2018-08-01 09:07:47 +0200
committerMiguel Molina <miguel@erizocosmi.co>2018-08-01 11:07:34 +0200
commitb173cc03edd25af3e868d83037168663ef84a329 (patch)
tree1fe466ab40e697139a917f4ed4ed7099424a57be /plumbing/format/idxfile/idxfile.go
parentd314e86c179f755ca9c92c60d6b0aedd9f568767 (diff)
parent6f7fc05543861ee074aa17f75e1d1b5c1b948d48 (diff)
downloadgo-git-b173cc03edd25af3e868d83037168663ef84a329.tar.gz
Merge pull request #907 from erizocosmico/feature/fix-tests
plumbing: packfile, fix package tests Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Diffstat (limited to 'plumbing/format/idxfile/idxfile.go')
-rw-r--r--plumbing/format/idxfile/idxfile.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/plumbing/format/idxfile/idxfile.go b/plumbing/format/idxfile/idxfile.go
index d4a9365..71c7630 100644
--- a/plumbing/format/idxfile/idxfile.go
+++ b/plumbing/format/idxfile/idxfile.go
@@ -67,6 +67,10 @@ func (idx *MemoryIndex) findHashIndex(h plumbing.Hash) int {
return -1
}
+ if len(idx.Names) <= k {
+ return -1
+ }
+
data := idx.Names[k]
high := uint64(len(idx.Offset32[k])) >> 2
if high == 0 {
@@ -103,6 +107,10 @@ func (idx *MemoryIndex) Contains(h plumbing.Hash) (bool, error) {
// FindOffset implements the Index interface.
func (idx *MemoryIndex) FindOffset(h plumbing.Hash) (int64, error) {
+ if len(idx.FanoutMapping) <= int(h[0]) {
+ return 0, plumbing.ErrObjectNotFound
+ }
+
k := idx.FanoutMapping[h[0]]
i := idx.findHashIndex(h)
if i < 0 {