diff options
author | bitground <70304874+bitground@users.noreply.github.com> | 2020-09-14 17:03:09 +0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-10-26 16:36:00 -0700 |
commit | b031143f8ab61296ddbf6c4470c5dcdbf7ae588b (patch) | |
tree | 39ad84ea0e932ddfd496b6543b5880a0f6fab53b /cache.c | |
parent | 6b319c8c7a29e9c353dec83dc92f01905f6c8966 (diff) | |
download | memcached-b031143f8ab61296ddbf6c4470c5dcdbf7ae588b.tar.gz |
Fix over-freeing in internal object cache
When returning item to the cache and the items allocated exceeded cache->limit, we should free the item and not put it to the cache.
The current code will free any item that tried returned to the cache when cache->total < cache->limit which is true in most cases if the total objects has never exceeded the limit.
Diffstat (limited to 'cache.c')
-rw-r--r-- | cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -142,7 +142,7 @@ void do_cache_free(cache_t *cache, void *ptr) { } ptr = pre; #endif - if (cache->limit > cache->total) { + if (cache->limit != 0 && cache->limit < cache->total) { /* Allow freeing in case the limit was revised downward */ if (cache->destructor) { cache->destructor(ptr, NULL); |