From 3b09f197d5361447c023d8bd52bc2eb56f96229a Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 19 Apr 2019 23:41:40 -0400 Subject: [PATCH] Fix use uninitialized Former-commit-id: 88e593bf967487835eaadf700abb3761e34306cb --- src/evict.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/evict.cpp b/src/evict.cpp index 1affbe445..1ba2ab934 100644 --- a/src/evict.cpp +++ b/src/evict.cpp @@ -167,7 +167,7 @@ void evictionPoolPopulate(int dbid, dict *sampledict, dict *keydict, struct evic for (j = 0; j < count; j++) { unsigned long long idle; sds key; - robj *o; + robj *o = nullptr; dictEntry *de; de = samples[j]; @@ -185,7 +185,7 @@ void evictionPoolPopulate(int dbid, dict *sampledict, dict *keydict, struct evic * idle just because the code initially handled LRU, but is in fact * just a score where an higher score means better candidate. */ if (server.maxmemory_policy & MAXMEMORY_FLAG_LRU) { - idle = estimateObjectIdleTime(o); + idle = (o != nullptr) ? estimateObjectIdleTime(o) : 0; } else if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) { /* When we use an LRU policy, we sort the keys by idle time * so that we expire keys starting from greater idle time.