Commit 05b85ebe authored by Daniel Melani's avatar Daniel Melani
Browse files

Less surprising behaviour.

Make redisFree() and freeReplyObject() less surprising by behaving just
like free(). That is, don't crash when passing in NULL.
parent f225c276
...@@ -73,6 +73,9 @@ void freeReplyObject(void *reply) { ...@@ -73,6 +73,9 @@ void freeReplyObject(void *reply) {
redisReply *r = reply; redisReply *r = reply;
size_t j; size_t j;
if (r == NULL)
return;
switch(r->type) { switch(r->type) {
case REDIS_REPLY_INTEGER: case REDIS_REPLY_INTEGER:
break; /* Nothing to free */ break; /* Nothing to free */
...@@ -1001,6 +1004,8 @@ static redisContext *redisContextInit(void) { ...@@ -1001,6 +1004,8 @@ static redisContext *redisContextInit(void) {
} }
void redisFree(redisContext *c) { void redisFree(redisContext *c) {
if (c == NULL)
return;
if (c->fd > 0) if (c->fd > 0)
close(c->fd); close(c->fd);
if (c->obuf != NULL) if (c->obuf != NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment