From c9fcdd908d74a33842eb9bc1072783b11ce9a21e Mon Sep 17 00:00:00 2001 From: evantsai Date: Mon, 11 Jan 2021 19:30:26 +0800 Subject: [PATCH] modify slots_async.c fix coredump: slot async migration with hash tag --- extern/redis-4.0.1/src/slots_async.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extern/redis-4.0.1/src/slots_async.c b/extern/redis-4.0.1/src/slots_async.c index fa0c90943..fde7fcb39 100644 --- a/extern/redis-4.0.1/src/slots_async.c +++ b/extern/redis-4.0.1/src/slots_async.c @@ -590,14 +590,16 @@ batchedObjectIteratorAddKey(redisDb *db, batchedObjectIterator *it, robj *key) { zskiplistNode *node = zslFirstInRange(it->hash_tags, &range); while (node != NULL && node->score == (double)crc) { node = node->level[0].forward; - keyCopy = sdsdup(node->ele); - if (dictAdd(it->keys, keyCopy, NULL) != C_OK) { - sdsfree(keyCopy); - continue; + if (node) { + keyCopy = sdsdup(node->ele); + if (dictAdd(it->keys, keyCopy, NULL) != C_OK) { + sdsfree(keyCopy); + continue; + } + robj *key = createObject(OBJ_STRING, sdsdup(node->ele)); + listAddNodeTail(it->list, createSingleObjectIterator(key)); + it->estimate_msgs += estimateNumberOfRestoreCommands(db, key, it->maxbulks); } - robj *key = createObject(OBJ_STRING, sdsdup(node->ele)); - listAddNodeTail(it->list, createSingleObjectIterator(key)); - it->estimate_msgs += estimateNumberOfRestoreCommands(db, key, it->maxbulks); } out: