]> git.saurik.com Git - redis.git/commitdiff
free hash table entries about no longer active classes, so that PUBSUB can be abused...
authorantirez <antirez@gmail.com>
Mon, 29 Mar 2010 10:33:41 +0000 (12:33 +0200)
committerantirez <antirez@gmail.com>
Mon, 29 Mar 2010 10:33:41 +0000 (12:33 +0200)
redis.c

diff --git a/redis.c b/redis.c
index 6e450aaf480c2845ba49f33aae00b13de4c792cc..650e11e42fbb5561d5e1544c8d8f0cff7b347616 100644 (file)
--- 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) {