summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2018-05-13 18:08:57 -0700
committermichael-grunder <michael.grunder@gmail.com>2018-05-13 18:08:57 -0700
commit7a1acdfeb58b3e3a84a7b5d34af5ec1daae0f603 (patch)
treec936a04bdcf6ad8079a20a4e61aa1fbfb9def6f7 /read.c
parentc1af0e849d6387a4297a1e1066c107f6f72d8469 (diff)
parent58e6b87f51ba31b4a2954d0babe6b3cf7019c985 (diff)
Merge remote-tracking branch 'justinbrewer/hiredis-pr1' into posix-build-fixes
Diffstat (limited to 'read.c')
-rw-r--r--read.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/read.c b/read.c
index 061bbda..2bad85e 100644
--- a/read.c
+++ b/read.c
@@ -52,11 +52,9 @@ static void __redisReaderSetError(redisReader *r, int type, const char *str) {
}
/* Clear input buffer on errors. */
- if (r->buf != NULL) {
- sdsfree(r->buf);
- r->buf = NULL;
- r->pos = r->len = 0;
- }
+ sdsfree(r->buf);
+ r->buf = NULL;
+ r->pos = r->len = 0;
/* Reset task stack. */
r->ridx = -1;
@@ -420,8 +418,6 @@ redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn) {
if (r == NULL)
return NULL;
- r->err = 0;
- r->errstr[0] = '\0';
r->fn = fn;
r->buf = sdsempty();
r->maxbuf = REDIS_READER_MAX_BUF;
@@ -435,10 +431,11 @@ redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn) {
}
void redisReaderFree(redisReader *r) {
+ if (r == NULL)
+ return;
if (r->reply != NULL && r->fn && r->fn->freeObject)
r->fn->freeObject(r->reply);
- if (r->buf != NULL)
- sdsfree(r->buf);
+ sdsfree(r->buf);
free(r);
}