Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/t_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ void hsetexCommand(client *c) {
robj **new_argv = NULL;
int new_argc = 0;

for (; fields_index < c->argc; fields_index++) {
for (; fields_index < c->argc - 1; fields_index++) {
if (!strcasecmp(c->argv[fields_index]->ptr, "fields")) {
/* checking optional flags */
if (parseExtendedCommandArgumentsOrReply(c, &flags, &unit, &expire, &comparison, COMMAND_HSET, fields_index++) != C_OK) return;
Expand Down Expand Up @@ -1358,7 +1358,7 @@ void hgetexCommand(client *c) {
int new_argc = 0;
int milliseconds_index = -1, numitems_index = -1;

for (; fields_index < c->argc; fields_index++) {
for (; fields_index < c->argc - 1; fields_index++) {
if (!strcasecmp(c->argv[fields_index]->ptr, "fields")) {
/* checking optional flags */
if (parseExtendedCommandArgumentsOrReply(c, &flags, &unit, &expire, &comparison, COMMAND_HGET, fields_index++) != C_OK) return;
Expand Down Expand Up @@ -1611,7 +1611,7 @@ void hexpireGenericCommand(client *c, long long basetime, int unit) {
robj **new_argv = NULL;
int new_argc = 0;

for (; fields_index < c->argc; fields_index++) {
for (; fields_index < c->argc - 1; fields_index++) {
if (!strcasecmp(c->argv[fields_index]->ptr, "fields")) {
/* checking optional flags */
if (parseExtendedExpireArgumentsOrReply(c, &flag, fields_index++) != C_OK) return;
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/hashexpire.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2053,6 +2053,16 @@ start_server {tags {"hashexpire"}} {
assert_morethan [r HTTL myhash FIELDS 1 f1] 0
assert_equal 1 [get_keys_with_volatile_items r]
}

test {Verify error when hash expire commands num fields is not provided} {
r FLUSHALL
catch {r hsetex myhash KEEPTTL KEEPTTL KEEPTTL FIELDS} e
assert_match $e {ERR numfields should be greater than 0 and match the provided number of fields}
catch {r hexpire myhash 10 NX NX FIELDS} e
assert_match $e {ERR numfields should be greater than 0 and match the provided number of fields}
catch {r hgetex myhash PERSIST PERSIST FIELDS} e
assert_match $e {ERR numfields should be greater than 0 and match the provided number of fields}
}
}

####### Test info
Expand Down
Loading