From 54136316b31afbee3330fcdccfba5380a9a12cc8 Mon Sep 17 00:00:00 2001 From: Pei-Hsuan Hung Date: Mon, 14 Jun 2021 10:32:44 +0800 Subject: [PATCH] Fix potential fault at createDoubleObject Resolves #963. Add additional check to `hi_malloc` for `r->str` when len+1 equals to 0. --- hiredis.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hiredis.c b/hiredis.c index 58251742c..933282432 100644 --- a/hiredis.c +++ b/hiredis.c @@ -231,6 +231,11 @@ static void *createDoubleObject(const redisReadTask *task, double value, char *s freeReplyObject(r); return NULL; } + else if (len+1 == 0) { + hi_free(r->str); + freeReplyObject(r); + return NULL; + } /* The double reply also has the original protocol string representing a * double as a null terminated string. This way the caller does not need