From a23cdbb94b25fda7f49c421c94c85830d0a526c6 Mon Sep 17 00:00:00 2001 From: ShooterIT Date: Tue, 5 May 2020 23:09:45 +0800 Subject: [PATCH] Redis Benchmark: Fix coredump because of double free --- src/redis-benchmark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 77daf981c..34295147d 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -279,7 +279,7 @@ static redisConfig *getRedisConfig(const char *ip, int port, for (; i < 2; i++) { int res = redisGetReply(c, &r); if (reply) freeReplyObject(reply); - reply = ((redisReply *) r); + reply = res == REDIS_OK ? ((redisReply *) r) : NULL; if (res != REDIS_OK || !r) goto fail; if (reply->type == REDIS_REPLY_ERROR) { fprintf(stderr, "ERROR: %s\n", reply->str);