Fixed issue #516 (ZINTERSTORE mixing sets and zsets).

Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
This commit is contained in:
antirez
2012-05-23 11:02:38 +02:00
parent afc6bd1b48
commit 4dada1b5bc
2 changed files with 10 additions and 1 deletions

View File

@ -1259,10 +1259,11 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
if (op->type == REDIS_SET) {
iterset *it = &op->iter.set;
if (op->encoding == REDIS_ENCODING_INTSET) {
int64_t ell = val->ell;
int64_t ell;
if (!intsetGet(it->is.is,it->is.ii,&ell))
return 0;
val->ell = ell;
val->score = 1.0;
/* Move to next element. */