From 50cdcab49d539e4703018185992abf3214088e85 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 equals to SIZE_MAX. --- hiredis.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hiredis.c b/hiredis.c index 7e7af82..ba77a77 100644 --- a/hiredis.c +++ b/hiredis.c @@ -221,6 +221,9 @@ static void *createIntegerObject(const redisReadTask *task, long long value) { static void *createDoubleObject(const redisReadTask *task, double value, char *str, size_t len) { redisReply *r, *parent; + if (len == SIZE_MAX) // Prevents hi_malloc(0) if len equals to SIZE_MAX + return NULL; + r = createReplyObject(REDIS_REPLY_DOUBLE); if (r == NULL) return NULL;