fix: zunion and zunionstore zero numkeys bug (#1522)

Fixes #1442

Signed-off-by: rounaknandanwar <rounak.nandanwar@gmail.com>
This commit is contained in:
Rounak Nandanwar 2023-07-10 12:20:59 +05:30 committed by GitHub
parent 4eb2012a8d
commit 674f06875c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -1445,12 +1445,14 @@ OpResult<KeyIndex> DetermineKeys(const CommandId* cid, CmdArgList args) {
if (!absl::SimpleAtoi(num, &num_custom_keys) || num_custom_keys < 0)
return OpStatus::INVALID_INT;
// TODO Fix this for Z family functions.
// Examples that crash: ZUNION 0 myset
if (name == "ZDIFF" && num_custom_keys == 0) {
return OpStatus::INVALID_INT;
}
if (name == "ZUNION" && num_custom_keys == 0) {
return OpStatus::SYNTAX_ERR;
}
if (args.size() < size_t(num_custom_keys) + num_keys_index + 1)
return OpStatus::SYNTAX_ERR;
}