Skip to content

Commit

Permalink
calloc param fixes and NULL check
Browse files Browse the repository at this point in the history
  • Loading branch information
cdliuqiang authored and badboy committed Jan 5, 2018
1 parent 43284ee commit 9219556
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions hiredis.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ redisContext *redisConnectNonBlock(const char *ip, int port) {
redisContext *redisConnectBindNonBlock(const char *ip, int port,
const char *source_addr) {
redisContext *c = redisContextInit();
if (c == NULL)
return NULL;
c->flags &= ~REDIS_BLOCK;
redisContextConnectBindTcp(c,ip,port,NULL,source_addr);
return c;
Expand All @@ -718,6 +720,8 @@ redisContext *redisConnectBindNonBlock(const char *ip, int port,
redisContext *redisConnectBindNonBlockWithReuse(const char *ip, int port,
const char *source_addr) {
redisContext *c = redisContextInit();
if (c == NULL)
return NULL;
c->flags &= ~REDIS_BLOCK;
c->flags |= REDIS_REUSEADDR;
redisContextConnectBindTcp(c,ip,port,NULL,source_addr);
Expand Down
2 changes: 1 addition & 1 deletion read.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ static int processItem(redisReader *r) {
redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn) {
redisReader *r;

r = calloc(sizeof(redisReader),1);
r = calloc(1,sizeof(redisReader));
if (r == NULL)
return NULL;

Expand Down

0 comments on commit 9219556

Please sign in to comment.