Skip to content

Commit

Permalink
fix data race crash in memory cache
Browse files Browse the repository at this point in the history
Merge pull request ibireme#153
  • Loading branch information
wbcyclist committed May 21, 2020
1 parent d6d783d commit 12f9e52
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion YYCache/YYMemoryCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ - (id)objectForKey:(id)key {
node->_time = CACurrentMediaTime();
[_lru bringNodeToHead:node];
}
id value = node ? node->_value : nil;
pthread_mutex_unlock(&_lock);
return node ? node->_value : nil;
return value;
}

- (void)setObject:(id)object forKey:(id)key {
Expand Down

0 comments on commit 12f9e52

Please sign in to comment.