From 91d3b487e7d27454a0562e4131f9ab79c8288074 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 12 Mar 2013 09:57:49 +0100 Subject: [PATCH] redis-cli --bigkeys: don't crash with empty DBs. --- src/redis-cli.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/redis-cli.c b/src/redis-cli.c index 496c18604..391cbd285 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1206,7 +1206,11 @@ static void findBigKeys(void) { fprintf(stderr, "RANDOMKEY error: %s\n", reply1->str); exit(1); + } else if (reply1->type == REDIS_REPLY_NIL) { + fprintf(stderr, "It looks like the database is empty!\n"); + exit(1); } + /* Get the key type */ reply2 = redisCommand(context,"TYPE %s",reply1->str); assert(reply2 && reply2->type == REDIS_REPLY_STATUS); -- GitLab