Skip to content

Commit

Permalink
Fix potential fault at createDoubleObject
Browse files Browse the repository at this point in the history
Resolves #963.

Add additional check to `hi_malloc` for `r->str` when len equals to
SIZE_MAX.
  • Loading branch information
afcidk committed Nov 1, 2021
1 parent c98c699 commit 50cdcab
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hiredis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 50cdcab

Please sign in to comment.