From de8d32023089333d6b05ac361b9c2f2ecc386868 Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Thu, 10 Sep 2020 10:09:13 +0300 Subject: [PATCH] Fix RESP3 response for HKEYS/HVALS on non-existing key (#7781) --- src/t_hash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/t_hash.c b/src/t_hash.c index e6f7b6be9..8421223cd 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -766,7 +766,9 @@ void genericHgetallCommand(client *c, int flags) { hashTypeIterator *hi; int length, count = 0; - if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptymap[c->resp])) + robj *emptyResp = (flags & OBJ_HASH_KEY && flags & OBJ_HASH_VALUE) ? + shared.emptymap[c->resp] : shared.emptyarray; + if ((o = lookupKeyReadOrReply(c,c->argv[1],emptyResp)) == NULL || checkType(c,o,OBJ_HASH)) return; /* We return a map if the user requested keys and values, like in the