mirror of
https://github.com/php/php-src.git
synced 2024-12-01 05:43:38 +08:00
Fixed segfault while OOM in pack_to_hash
This commit is contained in:
parent
69dbfa8e9f
commit
ded3a44cfd
@ -191,14 +191,15 @@ ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed)
|
||||
|
||||
ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht)
|
||||
{
|
||||
void *old_data = HT_GET_DATA_ADDR(ht);
|
||||
void *new_data, *old_data = HT_GET_DATA_ADDR(ht);
|
||||
Bucket *old_buckets = ht->arData;
|
||||
|
||||
HT_ASSERT(GC_REFCOUNT(ht) == 1);
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
ht->u.flags &= ~HASH_FLAG_PACKED;
|
||||
new_data = pemalloc(HT_SIZE(ht), (ht)->u.flags & HASH_FLAG_PERSISTENT);
|
||||
ht->nTableMask = -ht->nTableSize;
|
||||
HT_SET_DATA_ADDR(ht, pemalloc(HT_SIZE(ht), (ht)->u.flags & HASH_FLAG_PERSISTENT));
|
||||
HT_SET_DATA_ADDR(ht, new_data);
|
||||
memcpy(ht->arData, old_buckets, sizeof(Bucket) * ht->nNumUsed);
|
||||
pefree(old_data, (ht)->u.flags & HASH_FLAG_PERSISTENT);
|
||||
zend_hash_rehash(ht);
|
||||
|
Loading…
Reference in New Issue
Block a user