From 85cbb6ceba5a3cb8ac4e2335a3d04354b45e67b3 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 31 Jan 2023 08:06:00 -0500 Subject: [PATCH] MT#55628 fix possible segfault Don't try to free a NULL pointer after an error. Change-Id: I0951825910c321797159805c9445302049fc88a1 --- medredis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/medredis.c b/medredis.c index 421d614..f60d27f 100644 --- a/medredis.c +++ b/medredis.c @@ -226,15 +226,15 @@ static int medredis_get_reply(redisReply **reply) { /**********************************************************************/ static void medredis_consume_replies(void) { medredis_command_t *cmd; - redisReply *reply; + redisReply *reply = NULL; while (con->append_counter > 0) { - redisGetReply(con->ctx, (void**)&reply); - if (reply) { + int ret = redisGetReply(con->ctx, (void**)&reply); + if (ret == REDIS_OK) { con->append_counter--; + medredis_free_reply(&reply); } else { con->append_counter = 0; } - medredis_free_reply(&reply); } while ((cmd = g_queue_pop_head(con->command_queue))) { medredis_free_command(cmd);