From 386e20c94fa1be6c16194843eb8990601befbbdd Mon Sep 17 00:00:00 2001 From: Sree Oggu Date: Wed, 17 Apr 2024 13:45:07 -0700 Subject: [PATCH] XPC-20740:(goburrow-cache 1.0.3) GetActive() seg faults in very very corner case once in a while --- local.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/local.go b/local.go index c9f9447..21d4fbc 100644 --- a/local.go +++ b/local.go @@ -195,7 +195,7 @@ func (c *localCache) GetActive(k Key) (Value, error) { return nil, err } en := c.cache.get(k, sum(k)) - if ! en.getInvalidated() { + if en != nil && ! en.getInvalidated() { return obj, nil } return nil, errors.New ("entry invalidated") @@ -205,7 +205,7 @@ func (c *localCache) GetActive(k Key) (Value, error) { func (c *localCache) GetAllKeys() []interface{} { keys := make([]interface{}, 0, c.cache.len()) c.cache.walk(func(en *entry) { - if ! en.getInvalidated() { + if en != nil && ! en.getInvalidated() { keys = append(keys, en.key) } }) @@ -216,7 +216,7 @@ func (c *localCache) GetAllKeys() []interface{} { func (c *localCache) GetAllValues() []interface{} { values := make([]interface{}, 0, c.cache.len()) c.cache.walk(func(en *entry) { - if ! en.getInvalidated() { + if en != nil && ! en.getInvalidated() { values = append(values, en.getValue()) } }) @@ -227,7 +227,7 @@ func (c *localCache) GetAllValues() []interface{} { func (c *localCache) GetAll() map[interface{}]interface{} { var values = make(map[interface{}]interface{}, c.cache.len()) c.cache.walk(func(en *entry) { - if ! en.getInvalidated() { + if en != nil && ! en.getInvalidated() { values[en.key] = en.getValue() } })