From bbec4569a57df0ee14e64f64caa6bb0b12c7f9db Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 24 Jan 2018 16:47:39 +0100 Subject: [PATCH] CG: Fix order of calls in streamReplyWithRange(). We need to check if we are going to serve the request via the PEL before inserting a deferred array len in the client output buffer. --- src/t_stream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/t_stream.c b/src/t_stream.c index 605d3251..1d1dd894 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -694,7 +694,7 @@ size_t streamReplyWithRangeFromConsumerPEL(client *c, stream *s, streamID *start * 'noack' is non-zero. */ size_t streamReplyWithRange(client *c, stream *s, streamID *start, streamID *end, size_t count, int rev, streamCG *group, streamConsumer *consumer, int noack) { - void *arraylen_ptr = addDeferredMultiBulkLength(c); + void *arraylen_ptr; size_t arraylen = 0; streamIterator si; int64_t numfields; @@ -713,6 +713,7 @@ size_t streamReplyWithRange(client *c, stream *s, streamID *start, streamID *end group,consumer); } + arraylen_ptr = addDeferredMultiBulkLength(c); streamIteratorStart(&si,s,start,end,rev); while(streamIteratorGetID(&si,&id,&numfields)) { /* Update the group last_id if needed. */