From 115d076d655d265ef534bb0782da8a2ba0d877ac Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 21 Nov 2017 22:21:37 +0100 Subject: [PATCH] Streams: fix lp-count field for non-same-fields entries. --- src/t_stream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/t_stream.c b/src/t_stream.c index 837a812a..213a46bb 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -308,8 +308,12 @@ int streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id, } /* Compute and store the lp-count field. */ int lp_count = numfields; - if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) lp_count *= 2; - lp_count += 3; /* Add the 3 fixed fileds flags + ms-diff + seq-diff. */ + lp_count += 3; /* Add the 3 fixed fields flags + ms-diff + seq-diff. */ + if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) { + /* If the item is not compressed, it also has the fields other than + * the values, and an additional num-fileds field. */ + lp_count += numfields+1; + } lp = lpAppendInteger(lp,lp_count); /* Insert back into the tree in order to update the listpack pointer. */