Skip to content

Commit

Permalink
Fix possibility of a wrong element being deleted by zend_hash_del()
Browse files Browse the repository at this point in the history
Thanks Stefan!
  • Loading branch information
zsuraski committed Feb 1, 2006
1 parent 0249f6b commit b73349d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,10 @@ ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLen

p = ht->arBuckets[nIndex];
while (p != NULL) {
if ((p->h == h) && ((p->nKeyLength == 0) || /* Numeric index */
((p->nKeyLength == nKeyLength) && (!memcmp(p->arKey, arKey, nKeyLength))))) {
if ((p->h == h)
&& (p->nKeyLength == nKeyLength)
&& ((p->nKeyLength == 0) /* Numeric index (short circuits the memcmp() check) */
|| !memcmp(p->arKey, arKey, nKeyLength))) { /* String index */
HANDLE_BLOCK_INTERRUPTIONS();
if (p == ht->arBuckets[nIndex]) {
ht->arBuckets[nIndex] = p->pNext;
Expand Down

0 comments on commit b73349d

Please sign in to comment.