Skip to content

Commit

Permalink
XPC-20740:(goburrow-cache 1.0.3) GetActive() seg faults in very very …
Browse files Browse the repository at this point in the history
…corner case once in a while
  • Loading branch information
soggu46 committed Apr 17, 2024
1 parent 91cafc5 commit 386e20c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
})
Expand All @@ -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())
}
})
Expand All @@ -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()
}
})
Expand Down

0 comments on commit 386e20c

Please sign in to comment.