Skip to content

Commit 8675380

Browse files
committed
Increment refcounts in mutable data copies
For mutable_data on preloaded classes, there may be refcounted values in the constants/properties table.
1 parent ccb6642 commit 8675380

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Zend/zend_API.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,7 @@ ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_
13271327
memcpy(new_c, c, sizeof(zend_class_constant));
13281328
c = new_c;
13291329
}
1330+
Z_TRY_ADDREF(c->value);
13301331
_zend_hash_append_ptr(constants_table, key, c);
13311332
} ZEND_HASH_FOREACH_END();
13321333

@@ -1437,7 +1438,7 @@ ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type) /
14371438
dst = default_properties_table;
14381439
end = dst + class_type->default_properties_count;
14391440
do {
1440-
ZVAL_COPY_VALUE_PROP(dst, src);
1441+
ZVAL_COPY_PROP(dst, src);
14411442
src++;
14421443
dst++;
14431444
} while (dst != end);

ext/opcache/tests/preload_enum.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ enum MyEnum {
55
case Bar;
66
}
77
var_dump(MyEnum::Bar);
8+
9+
class Test {
10+
public $x = MyEnum::Bar;
11+
}
12+
new Test;

0 commit comments

Comments
 (0)