Streams: fix backward iteration when entry is not flagged SAMEFIELD.

See issue #5006. The comment in the code was also wrong and
was rectified as well.
This commit is contained in:
antirez 2018-06-12 10:22:03 +02:00
parent 82661ba329
commit 7cc1312789

View File

@ -647,7 +647,12 @@ int streamIteratorGetID(streamIterator *si, streamID *id, int64_t *numfields) {
for (int64_t i = 0; i < to_discard; i++)
si->lp_ele = lpNext(si->lp,si->lp_ele);
} else {
int prev_times = 4; /* flag + id ms/seq diff + numfields. */
int prev_times = 4; /* flag + id ms + id seq + one more to
go back to the previous entry "count"
field. */
/* If the entry was not flagged SAMEFIELD we also read the
* number of fields, so go back one more. */
if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) prev_times++;
while(prev_times--) si->lp_ele = lpPrev(si->lp,si->lp_ele);
}
}