summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Melani <daniel.melani@gmail.com>2014-05-29 16:05:27 +0200
committerDaniel Melani <daniel.melani@gmail.com>2014-05-29 16:05:27 +0200
commit05b85ebe7ffcfe41f084b6f46ab49a4f21c0eb22 (patch)
tree326e35cfa7d1b50b49fdc7c9c65dd5d3c1f1391e
parentf225c276be7fd0646019b51023e3f41566633dfe (diff)
Less surprising behaviour.
Make redisFree() and freeReplyObject() less surprising by behaving just like free(). That is, don't crash when passing in NULL.
-rw-r--r--hiredis.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hiredis.c b/hiredis.c
index 2afee56..78beaae 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -73,6 +73,9 @@ void freeReplyObject(void *reply) {
redisReply *r = reply;
size_t j;
+ if (r == NULL)
+ return;
+
switch(r->type) {
case REDIS_REPLY_INTEGER:
break; /* Nothing to free */
@@ -1001,6 +1004,8 @@ static redisContext *redisContextInit(void) {
}
void redisFree(redisContext *c) {
+ if (c == NULL)
+ return;
if (c->fd > 0)
close(c->fd);
if (c->obuf != NULL)