diff options
author | antirez <antirez@gmail.com> | 2015-04-28 22:00:48 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-04-28 22:00:48 +0200 |
commit | 2fc39eb4c35ad6c66a1b832a81d1519dcf5fe856 (patch) | |
tree | 4e9ce6b54b4f242388472ab5aebf4e7232e77aed | |
parent | d8145d79ce715054980938c751067ebaa541573c (diff) | |
download | hiredict-2fc39eb4c35ad6c66a1b832a81d1519dcf5fe856.tar.xz |
Fix memory leak in async spontaneous reply handling
When an asynchronous hiredis connection subscribes to a Pub/Sub channel
and gets an error, and in other related conditions, the function
redisProcessCallbacks() enters a code path where the link is
disconnected, however the function returns before freeing the allocated
reply object. This causes a memory leak. The memory leak was trivial to
trigger in Redis Sentinel, which uses hiredis, every time we tried to
subscribe to an instance that required a password, in case the Sentinel
was configured either with the wrong password or without password at
all. In this case, the -AUTH error caused the leaking code path to be
executed.
-rw-r--r-- | async.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -454,6 +454,7 @@ void redisProcessCallbacks(redisAsyncContext *ac) { if (((redisReply*)reply)->type == REDIS_REPLY_ERROR) { c->err = REDIS_ERR_OTHER; snprintf(c->errstr,sizeof(c->errstr),"%s",((redisReply*)reply)->str); + c->reader->fn->freeObject(reply); __redisAsyncDisconnect(ac); return; } |