diff --git a/src/pubsub.c b/src/pubsub.c index a2c28ddcb..afe28f59b 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -350,6 +350,9 @@ void pubsubShardUnsubscribeAllChannelsInSlot(unsigned int slot) { } dictReleaseIterator(iter); kvstoreDictDelete(server.pubsubshard_channels, slot, channel); + /* After the dict becomes empty, the dict will be deleted. + * We break out without calling dictNext. */ + if (!kvstoreDictSize(server.pubsubshard_channels, slot)) break; } dictReleaseIterator(di); }