summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-09-19 20:41:03 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-09-19 20:41:03 +0200
commitc18b58899e6cad293983fbe522d241bc6a7ce436 (patch)
treef076ea8b0eac997e49f40f6a7fc50187a009857f
parent62c8054dbe5d590a7f2d36e4e5176996215e9aa7 (diff)
Use auxiliary variable to store reply before free'ing the list
-rw-r--r--hiredis.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hiredis.c b/hiredis.c
index fcda779..611a122 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -274,6 +274,7 @@ static int processItem(redisReader *r) {
#define READ_BUFFER_SIZE 2048
static redisReply *redisReadReply(int fd) {
+ redisReply *reply;
redisReader r;
int bytes;
@@ -319,9 +320,10 @@ static redisReply *redisReadReply(int fd) {
if (processItem(&r) < 0)
break;
}
+ reply = r.rlist[0];
free(r.buf);
free(r.rlist);
- return r.rlist[0];
+ return reply;
}
/* Helper function for redisCommand(). It's used to append the next argument