mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
fix: ZRANGE with LIMIT parameters crash fixed (#4944)
fixed: https://github.com/dragonflydb/dragonfly/issues/4943
This commit is contained in:
parent
9505d21047
commit
d21166211d
2 changed files with 9 additions and 0 deletions
|
@ -217,6 +217,9 @@ bool IterateSortedSet(const detail::RobjWrapper* robj_wrapper, const IterateSort
|
|||
if (end < 0 || unsigned(end) >= llen)
|
||||
end = llen - 1;
|
||||
|
||||
if (start > end || unsigned(start) >= llen)
|
||||
return true;
|
||||
|
||||
unsigned rangelen = unsigned(end - start) + 1;
|
||||
|
||||
if (robj_wrapper->encoding() == OBJ_ENCODING_LISTPACK) {
|
||||
|
|
|
@ -1212,4 +1212,10 @@ TEST_F(ZSetFamilyTest, RangeStore) {
|
|||
EXPECT_THAT(resp, ArrLen(0));
|
||||
}
|
||||
|
||||
TEST_F(ZSetFamilyTest, ZRangeZeroElements) {
|
||||
Run({"zadd", "myzset", "1", "one"});
|
||||
auto resp = Run({"ZRANGE", "myzset", "0", "-1", "LIMIT", "2", "10"});
|
||||
ASSERT_THAT(resp, ArrLen(0));
|
||||
}
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue