Skip to content

Commit 2057141

Browse files
committed
Make cached HashTables immutable
1 parent 3e9da35 commit 2057141

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/opcache/ZendAccelerator.c

+10
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,11 @@ static zend_ffi_type* accel_ffi_persist_type_copy(void** ptr, zend_ffi_type *typ
25932593
break;
25942594
case ZEND_FFI_TYPE_STRUCT:
25952595
ht = &new_type->record.fields;
2596+
GC_SET_REFCOUNT(ht, 2);
2597+
GC_ADD_FLAGS(ht, IS_ARRAY_IMMUTABLE);
2598+
HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
2599+
ht->pDestructor = NULL;
2600+
ht->nInternalPointer = 0;
25962601
if (HT_IS_PACKED(ht)) {
25972602
memcpy(*ptr, ht->arPacked, HT_PACKED_USED_SIZE(ht));
25982603
ht->arPacked = (zval*)(*ptr);
@@ -2619,6 +2624,11 @@ static zend_ffi_type* accel_ffi_persist_type_copy(void** ptr, zend_ffi_type *typ
26192624
memcpy(ht, new_type->func.args, sizeof(HashTable));
26202625
(*ptr) = (void*)((char*)(*ptr) + sizeof(HashTable));
26212626
new_type->func.args = ht;
2627+
GC_SET_REFCOUNT(ht, 2);
2628+
GC_ADD_FLAGS(ht, IS_ARRAY_IMMUTABLE);
2629+
HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
2630+
ht->pDestructor = NULL;
2631+
ht->nInternalPointer = 0;
26222632
ZEND_ASSERT(HT_IS_PACKED(ht));
26232633
memcpy(*ptr, ht->arPacked, HT_PACKED_USED_SIZE(ht));
26242634
ht->arPacked = (zval*)(*ptr);

0 commit comments

Comments
 (0)