# Bug in zend_hash_init()

- Thread: https://externals.io/message/52054
- Original archive: https://news-web.php.net/php.internals/52054
- Started by Anton Dobkin on 2011-04-28T10:53:06+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #52054 — Anton Dobkin — 2011-04-28T10:53:06+00:00

URL: https://externals.io/message/52054#52054

Hi,

In function zend_hash_init() when allocate no persistent memory (if flag
persistent is 0) for arBuckets element of struct HashTable and virtual
memory is over,  the function always returns SUCCESS

Code:

       if (persistent) {
tmp = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
if (!tmp) {
return FAILURE;
}
ht->arBuckets = tmp;
} else {
                // No checking on return value?
tmp = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
if (tmp) {
ht->arBuckets = tmp;
        }
        }

---

## #52055 — Antony Dovgal — 2011-04-28T11:50:18+00:00

URL: https://externals.io/message/52054#52055 · In reply to: #52054

> // No checking on return value?

Yes, it doesn't check for NULL.
See ecalloc() sources in Zend/zend_alloc.c around line 2434 to see why.

-- 
Wbr,
Antony Dovgal
---
http://pinba.org - realtime statistics for PHP
