From ac0b186aa3ec12eb1730f2f58b702c30d3ed5789 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Thu, 12 Dec 2019 14:40:50 -0800 Subject: Free the reply in redisGetReply when passed NULL We currently perform a NULL check in redisGetReply and don't push the reply back to the caller, but we don't free any reply meaning that this will leak memory: redisGetReply(context, NULL); This change simply frees the reply if we were passed NULL. Addresses #740 --- hiredis.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'hiredis.c') diff --git a/hiredis.c b/hiredis.c index c461131..8e438f2 100644 --- a/hiredis.c +++ b/hiredis.c @@ -945,8 +945,13 @@ int redisGetReply(redisContext *c, void **reply) { } while (aux == NULL); } - /* Set reply object */ - if (reply != NULL) *reply = aux; + /* Set reply or free it if we were passed NULL */ + if (reply != NULL) { + *reply = aux; + } else { + freeReplyObject(aux); + } + return REDIS_OK; } -- cgit v1.2.3