diff options
author | Zeev Suraski <zeev@php.net> | 2000-01-17 18:09:03 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2000-01-17 18:09:03 +0000 |
commit | a965dc5b4082b8b39def3b1cd5f8431454bd32b6 (patch) | |
tree | 9040272cd9eb17bea8d4a3fc0853a3af2faf0e4a | |
parent | 62114c18068610dc02b7a28e74d3d2957e3315fd (diff) | |
download | php-git-a965dc5b4082b8b39def3b1cd5f8431454bd32b6.tar.gz |
- Fixes a newly introduced bug in the hash
-rw-r--r-- | Zend/zend_hash.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index f14da0efe9..03d9558395 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -714,7 +714,7 @@ ZEND_API int zend_hash_rehash(HashTable *ht) ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag) { uint nIndex; - Bucket *p, *t = NULL; /* initialize just to shut gcc up with -Wall */ + Bucket *p; /* initialize just to shut gcc up with -Wall */ IS_CONSISTENT(ht); @@ -729,10 +729,8 @@ ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLen if ((p->h == h) && ((p->nKeyLength == 0) || /* Numeric index */ ((p->nKeyLength == nKeyLength) && (!memcmp(p->arKey, arKey, nKeyLength))))) { HANDLE_BLOCK_INTERRUPTIONS(); - if (p == ht->arBuckets[nIndex]) { + if (ht->arBuckets[nIndex] == p) { ht->arBuckets[nIndex] = p->pNext; - } else { - t->pNext = p->pNext; } if (p->pListLast != NULL) { p->pListLast->pListNext = p->pListNext; @@ -761,7 +759,6 @@ ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLen ht->nNumOfElements--; return SUCCESS; } - t = p; p = p->pNext; } return FAILURE; @@ -837,9 +834,12 @@ ZEND_API void zend_hash_clean(HashTable *ht) static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p) { Bucket *retval; + uint nIndex; HANDLE_BLOCK_INTERRUPTIONS(); + nIndex = p->h % ht->nTableSize; + if (!p->bIsPointer) { if (ht->pDestructor) { ht->pDestructor(p->pData); @@ -850,6 +850,10 @@ static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p) } retval = p->pListNext; + if (ht->arBuckets[nIndex] == p) { + ht->arBuckets[nIndex] = p->pNext; + } + if (p->pListLast != NULL) { p->pListLast->pListNext = p->pListNext; } else { |