Fix invalid dictNext usage when pubsubshard_channels became empty (#13033)

After #12822, when pubsubshard_channels became empty, kvstoreDictDelete
will delete the dict (which is the only one currently deleting dicts
that
become empty) and in the next loop, we will make an invalid call to
dictNext.

After the dict becomes empty, we break out of the loop without calling
dictNext.
This commit is contained in:
Binbin 2024-02-06 19:41:02 +08:00 committed by GitHub
parent 13bd3643c2
commit 8096515432
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -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);
}