Skip to content

Commit e584d82

Browse files
committed
Return error to client on wrong type for HMGET
1 parent 244201f commit e584d82

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/t_hash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void hmgetCommand(redisClient *c) {
310310
o = lookupKeyRead(c->db,c->argv[1]);
311311
if (o != NULL && o->type != REDIS_HASH) {
312312
addReply(c,shared.wrongtypeerr);
313+
return;
313314
}
314315

315316
/* Note the check for o != NULL happens inside the loop. This is

tests/unit/type/hash.tcl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ start_server {tags {"hash"}} {
140140
set _ $rv
141141
} {{{} {}} {{} {}} {{} {}}}
142142

143+
test {HMGET against wrong type} {
144+
r set wrongtype somevalue
145+
assert_error "*wrong*" {r hmget wrongtype field1 field2}
146+
}
147+
143148
test {HMGET - small hash} {
144149
set keys {}
145150
set vals {}

0 commit comments

Comments
 (0)