add an assertion to make sure numkeys is 0 in getKeysUsingKeySpecs (#12389)

This is an addition to #12380, to prevent potential bugs when collecting
keys from multiple commands in the future.
Note that this function also resets numkeys in some cases.
This commit is contained in:
zhaozhao.zz 2023-07-06 13:17:25 +08:00 committed by GitHub
parent 1190f25ca7
commit aefdc57f1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1873,7 +1873,7 @@ int64_t getAllKeySpecsFlags(struct redisCommand *cmd, int inv) {
int getKeysUsingKeySpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) { int getKeysUsingKeySpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) {
int j, i, last, first, step; int j, i, last, first, step;
keyReference *keys; keyReference *keys;
result->numkeys = 0; serverAssert(result->numkeys == 0); /* caller should initialize or reset it */
for (j = 0; j < cmd->key_specs_num; j++) { for (j = 0; j < cmd->key_specs_num; j++) {
keySpec *spec = cmd->key_specs + j; keySpec *spec = cmd->key_specs + j;