Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
9dc79c03
Commit
9dc79c03
authored
Nov 17, 2017
by
antirez
Browse files
Streams: fix reverse iterator discarding of items out of range.
parent
6919280c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_stream.c
View file @
9dc79c03
...
...
@@ -597,11 +597,18 @@ int streamIteratorGetID(streamIterator *si, streamID *id, int64_t *numfields) {
}
}
/* If we do not emit, we have to discard. */
int
to_discard
=
(
flags
&
STREAM_ITEM_FLAG_SAMEFIELDS
)
?
*
numfields
:
*
numfields
*
2
;
for
(
int64_t
i
=
0
;
i
<
to_discard
;
i
++
)
si
->
lp_ele
=
lpNext
(
si
->
lp
,
si
->
lp_ele
);
/* If we do not emit, we have to discard if we are going
* forward, or seek the previous entry if we are going
* backward. */
if
(
!
si
->
rev
)
{
int
to_discard
=
(
flags
&
STREAM_ITEM_FLAG_SAMEFIELDS
)
?
*
numfields
:
*
numfields
*
2
;
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. */
while
(
prev_times
--
)
si
->
lp_ele
=
lpPrev
(
si
->
lp
,
si
->
lp_ele
);
}
}
/* End of listpack reached. Try the next/prev radix tree node. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment