Fix potential fault at createDoubleObject

Resolves #963.

Add additional check to `hi_malloc` for `r->str` when len equals to
SIZE_MAX.
master
Pei-Hsuan Hung 2021-06-14 10:32:44 +08:00
parent c98c6994de
commit 50cdcab49d
1 changed files with 3 additions and 0 deletions

View File

@ -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;