summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-09-19 16:57:37 +0200
committerantirez <antirez@gmail.com>2017-11-04 17:39:26 +0100
commita33b3650bfdb968034100230fcc77e8d83715f24 (patch)
treeeda16f5ba160b3495dd65b914b2ef576b864e7ee
parent2b2bbf03401fb03cb9f131a537fc362e624d3ac8 (diff)
downloadredis-a33b3650bfdb968034100230fcc77e8d83715f24.tar.gz
Streams: fixed memory leaks when blocking again for same stream.
blockForKeys() was not freeing the allocation holding the ID when the key was already found busy. Fortunately the unit test checked explicitly for blocking multiple times for the same key (copying a regression in the blocking lists tests), so the bug was detected by the Redis test leak checker.
-rw-r--r--src/blocked.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/blocked.c b/src/blocked.c
index 519a402cf..734e6ffd6 100644
--- a/src/blocked.c
+++ b/src/blocked.c
@@ -387,7 +387,10 @@ void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeo
}
/* If the key already exists in the dictionary ignore it. */
- if (dictAdd(c->bpop.keys,keys[j],key_data) != DICT_OK) continue;
+ if (dictAdd(c->bpop.keys,keys[j],key_data) != DICT_OK) {
+ zfree(key_data);
+ continue;
+ }
incrRefCount(keys[j]);
/* And in the other "side", to map keys -> clients */