From 4ee28bfc2c1f8482e0a70a4378f1e376f8076220 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 26 Aug 2022 17:29:54 +0800 Subject: [PATCH] fix: only iterate next when delete the specified node --- source/libs/executor/src/tsimplehash.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c index 8dce53273b..aeeb43632b 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/libs/executor/src/tsimplehash.c @@ -294,11 +294,13 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke pPrev->next = pNode->next; } - if (pNode->next) { - *pIter = GET_SHASH_NODE_DATA(pNode->next); - } else { - *pIter = NULL; - ++(*iter); + if (*pIter == (void*)GET_SHASH_NODE_DATA(pNode)) { + if (pNode->next) { + *pIter = GET_SHASH_NODE_DATA(pNode->next); + } else { + *pIter = NULL; + ++(*iter); + } } FREE_HASH_NODE(pNode);