free hash table entries about no longer active classes, so that PUBSUB can be abused with millions of different classes

This commit is contained in:
antirez 2010-03-29 12:33:41 +02:00
parent 201037f562
commit ff767a7580

View File

@ -9312,6 +9312,12 @@ static int pubsubUnsubscribe(redisClient *c, robj *class, int notify) {
ln = listSearchKey(clients,c); ln = listSearchKey(clients,c);
assert(ln != NULL); assert(ln != NULL);
listDelNode(clients,ln); 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 */ /* Notify the client */
if (notify) { if (notify) {