diff --git a/src/quicklist.c b/src/quicklist.c index c8517414c..7b7aa7839 100644 --- a/src/quicklist.c +++ b/src/quicklist.c @@ -999,7 +999,7 @@ int quicklistDelRange(quicklist *quicklist, const long start, * can just delete the entire node without ziplist math. */ delete_entire_node = 1; del = node->count; - } else if (entry.offset >= 0 && extent >= node->count) { + } else if (entry.offset >= 0 && extent + entry.offset >= node->count) { /* If deleting more nodes after this one, calculate delete based * on size of current node. */ del = node->count - entry.offset; @@ -2238,6 +2238,17 @@ int quicklistTest(int argc, char *argv[]) { quicklistRelease(ql); } + TEST("delete less than fill but across nodes") { + quicklist *ql = quicklistNew(-2, options[_i]); + quicklistSetFill(ql, 32); + for (int i = 0; i < 500; i++) + quicklistPushTail(ql, genstr("hello", i + 1), 32); + ql_verify(ql, 16, 500, 32, 20); + quicklistDelRange(ql, 60, 10); + ql_verify(ql, 16, 490, 32, 20); + quicklistRelease(ql); + } + TEST("delete negative 1 from 500 list") { quicklist *ql = quicklistNew(-2, options[_i]); quicklistSetFill(ql, 32);