From ff767a758086cac8797e611d3c5e9210a563a83b Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 29 Mar 2010 12:33:41 +0200 Subject: [PATCH] free hash table entries about no longer active classes, so that PUBSUB can be abused with millions of different classes --- redis.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/redis.c b/redis.c index 6e450aaf..650e11e4 100644 --- a/redis.c +++ b/redis.c @@ -9312,6 +9312,12 @@ static int pubsubUnsubscribe(redisClient *c, robj *class, int notify) { ln = listSearchKey(clients,c); assert(ln != NULL); listDelNode(clients,ln); + if (listLength(clients) == 0) { + /* Free the list and associated hash entry at all if this was + * the latest client, so that it will be possible to abuse + * Redis PUBSUB creating millions of classes. */ + dictDelete(server.pubsub_classes,class); + } } /* Notify the client */ if (notify) { -- 2.45.2