Skip to content

Commit

Permalink
add an assertion to make sure numkeys is 0 in getKeysUsingKeySpecs (r…
Browse files Browse the repository at this point in the history
…edis#12389)

This is an addition to redis#12380, to prevent potential bugs when collecting
keys from multiple commands in the future.
Note that this function also resets numkeys in some cases.
  • Loading branch information
soloestoy authored Jul 6, 2023
1 parent 1190f25 commit aefdc57
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 j, i, last, first, step;
keyReference *keys;
result->numkeys = 0;
serverAssert(result->numkeys == 0); /* caller should initialize or reset it */

for (j = 0; j < cmd->key_specs_num; j++) {
keySpec *spec = cmd->key_specs + j;
Expand Down

0 comments on commit aefdc57

Please sign in to comment.