From 3d2a77ea6d4c8e6c22e80dae08098bdf0d4fd8b3 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 17 Sep 2020 11:13:06 +0800 Subject: [PATCH] fix skiplist crash bug --- src/util/src/tskiplist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 73f6bf0502..c3e8ee41bd 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -466,7 +466,12 @@ static bool tSkipListGetPosToPut(SSkipList *pSkipList, SSkipListNode **forward, } SSkipListNode *px = pSkipList->pHead; - for (int i = pSkipList->level - 1; i >= 0; --i) { + for (int i = pNode->level - 1; i >= 0; --i) { + if (i >= pSkipList->level) { + forward[i] = pSkipList->pHead; + continue; + } + SSkipListNode *p = SL_GET_FORWARD_POINTER(px, i); while (p != pSkipList->pTail) { pKey = SL_GET_NODE_KEY(pSkipList, p); -- GitLab