From e584d82fecd13afa8de5e9c129789da6a70117d9 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Tue, 26 Oct 2010 12:26:27 +0200 Subject: [PATCH] Return error to client on wrong type for HMGET --- src/t_hash.c | 1 + tests/unit/type/hash.tcl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/t_hash.c b/src/t_hash.c index 5cef1cab..071b7754 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -310,6 +310,7 @@ void hmgetCommand(redisClient *c) { o = lookupKeyRead(c->db,c->argv[1]); if (o != NULL && o->type != REDIS_HASH) { addReply(c,shared.wrongtypeerr); + return; } /* Note the check for o != NULL happens inside the loop. This is diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 2c0bd534..8559dc3c 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -140,6 +140,11 @@ start_server {tags {"hash"}} { set _ $rv } {{{} {}} {{} {}} {{} {}}} + test {HMGET against wrong type} { + r set wrongtype somevalue + assert_error "*wrong*" {r hmget wrongtype field1 field2} + } + test {HMGET - small hash} { set keys {} set vals {} -- 2.45.2