From 6919280cc5eb9a35887ddaa528053380d584327a Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 17 Nov 2017 13:47:50 +0100 Subject: [PATCH] Streams: fix reverse iteration next node jumping. --- src/t_stream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/t_stream.c b/src/t_stream.c index 945fc28c..f64824c9 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -540,7 +540,11 @@ int streamIteratorGetID(streamIterator *si, streamID *id, int64_t *numfields) { * entry is composed of, and jump backward N times to seek * its start. */ int lp_count = lpGetInteger(si->lp_ele); - if (lp_count == 0) break; /* We reached the master entry. */ + if (lp_count == 0) { /* We reached the master entry. */ + si->lp = NULL; + si->lp_ele = NULL; + break; + } while(lp_count--) si->lp_ele = lpPrev(si->lp,si->lp_ele); }