aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/cache/object_lru.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-02-26 00:23:29 +0100
committerGitHub <noreply@github.com>2019-02-26 00:23:29 +0100
commit0106daba16494c33d330168e38c8a610b7a9b32c (patch)
treeda147d38dde5940994928e3d7096704fff4edc10 /plumbing/cache/object_lru.go
parentdb6c41c156481962abf9a55a324858674c25ab08 (diff)
parente9d0393809be173a2b28cb1a60b306468464c7fb (diff)
downloadgo-git-0106daba16494c33d330168e38c8a610b7a9b32c.tar.gz
Merge pull request #1076 from jfontan/panic-cache
plumbing/cache: check for empty cache list
Diffstat (limited to 'plumbing/cache/object_lru.go')
-rw-r--r--plumbing/cache/object_lru.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/plumbing/cache/object_lru.go b/plumbing/cache/object_lru.go
index 53d8b02..cd3712b 100644
--- a/plumbing/cache/object_lru.go
+++ b/plumbing/cache/object_lru.go
@@ -61,6 +61,11 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) {
c.actualSize += objSize
for c.actualSize > c.MaxSize {
last := c.ll.Back()
+ if last == nil {
+ c.actualSize = 0
+ break
+ }
+
lastObj := last.Value.(plumbing.EncodedObject)
lastSize := FileSize(lastObj.Size())