fix: only iterate next when delete the specified node

This commit is contained in:
Cary Xu 2022-08-26 17:29:54 +08:00
parent 5dcfa5a241
commit 4ee28bfc2c
1 changed files with 7 additions and 5 deletions

View File

@ -294,12 +294,14 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke
pPrev->next = pNode->next; pPrev->next = pNode->next;
} }
if (*pIter == (void*)GET_SHASH_NODE_DATA(pNode)) {
if (pNode->next) { if (pNode->next) {
*pIter = GET_SHASH_NODE_DATA(pNode->next); *pIter = GET_SHASH_NODE_DATA(pNode->next);
} else { } else {
*pIter = NULL; *pIter = NULL;
++(*iter); ++(*iter);
} }
}
FREE_HASH_NODE(pNode); FREE_HASH_NODE(pNode);
atomic_sub_fetch_64(&pHashObj->size, 1); atomic_sub_fetch_64(&pHashObj->size, 1);