From 8f00cf85a7ee93da987e8d0b899ada33f2a88505 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 19 Sep 2017 16:57:37 +0200 Subject: [PATCH] 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. --- src/blocked.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/blocked.c b/src/blocked.c index 519a402c..734e6ffd 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 */