From 451e621a944d78ffa2a400645118bc70e477f25d Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sat, 27 Aug 2022 18:04:33 +0800 Subject: [PATCH] fix: simple hash iterate remove and clear --- source/libs/executor/src/tsimplehash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c index aeeb43632b..b839fba543 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/libs/executor/src/tsimplehash.c @@ -294,12 +294,11 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke pPrev->next = pNode->next; } - if (*pIter == (void*)GET_SHASH_NODE_DATA(pNode)) { - if (pNode->next) { - *pIter = GET_SHASH_NODE_DATA(pNode->next); - } else { + if (*pIter == (void *)GET_SHASH_NODE_DATA(pNode)) { + if (!pPrev) { *pIter = NULL; - ++(*iter); + } else { + *pIter = pPrev; } } @@ -331,6 +330,7 @@ void tSimpleHashClear(SSHashObj *pHashObj) { FREE_HASH_NODE(pNode); pNode = pNext; } + pHashObj->hashList[i] = NULL; } atomic_store_64(&pHashObj->size, 0); }