diff --git a/redis.c b/redis.c index 3f75037da..04d8b0be4 100644 --- a/redis.c +++ b/redis.c @@ -5685,7 +5685,7 @@ static void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { addReplyLong(c, dstzset->zsl->length); server.dirty++; } else { - decrRefCount(dstzset); + decrRefCount(dstobj); addReply(c, shared.czero); } zfree(src); diff --git a/test-redis.tcl b/test-redis.tcl index 436722544..f7fe39b04 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -1489,6 +1489,11 @@ proc main {server port} { list [$r zremrangebyrank zset 1 3] [$r zrange zset 0 -1] } {3 {a e}} + test {ZUNION against non-existing key doesn't set destination} { + $r del zseta + list [$r zunion dst_key 1 zseta] [$r exists dst_key] + } {0 0} + test {ZUNION basics} { $r del zseta zsetb zsetc $r zadd zseta 1 a