diff --git a/src/redis-cli.c b/src/redis-cli.c index 2e13d3060..3526319d5 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -517,8 +517,11 @@ static int cliReadReply(int output_raw_strings) { int output = 1; if (redisGetReply(context,&_reply) != REDIS_OK) { - if (config.shutdown) + if (config.shutdown) { + redisFree(context); + context = NULL; return REDIS_OK; + } if (config.interactive) { /* Filter cases where we should reconnect */ if (context->err == REDIS_ERR_IO && errno == ECONNRESET)