Skip to content

Commit ebe2c3a

Browse files
committed
Make cached HashTables immutable
1 parent 3c066f5 commit ebe2c3a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,6 +2596,11 @@ static zend_ffi_type* accel_ffi_persist_type_copy(void** ptr, zend_ffi_type *typ
25962596
break;
25972597
case ZEND_FFI_TYPE_STRUCT:
25982598
ht = &new_type->record.fields;
2599+
GC_SET_REFCOUNT(ht, 2);
2600+
GC_ADD_FLAGS(ht, IS_ARRAY_IMMUTABLE);
2601+
HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
2602+
ht->pDestructor = NULL;
2603+
ht->nInternalPointer = 0;
25992604
if (HT_IS_PACKED(ht)) {
26002605
memcpy(*ptr, ht->arPacked, HT_PACKED_USED_SIZE(ht));
26012606
ht->arPacked = (zval*)(*ptr);
@@ -2622,6 +2627,11 @@ static zend_ffi_type* accel_ffi_persist_type_copy(void** ptr, zend_ffi_type *typ
26222627
memcpy(ht, new_type->func.args, sizeof(HashTable));
26232628
(*ptr) = (void*)((char*)(*ptr) + sizeof(HashTable));
26242629
new_type->func.args = ht;
2630+
GC_SET_REFCOUNT(ht, 2);
2631+
GC_ADD_FLAGS(ht, IS_ARRAY_IMMUTABLE);
2632+
HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
2633+
ht->pDestructor = NULL;
2634+
ht->nInternalPointer = 0;
26252635
ZEND_ASSERT(HT_IS_PACKED(ht));
26262636
memcpy(*ptr, ht->arPacked, HT_PACKED_USED_SIZE(ht));
26272637
ht->arPacked = (zval*)(*ptr);

0 commit comments

Comments
 (0)