Skip to content

Conversation

iluuu1994
Copy link
Member

The ZVAL_ARR macro always set the zval type_info to IS_ARRAY_EX, even if the hash table is immutable. Since in preg_replace_callback_array() we can return the passed array directly, and that passed array can be immutable, we need to reset the type_flags to keep the VM from performing ref-counting on the array.

Fixes GH-10968

We could also introduce a new macro for this but I couldn't find another place that potentially returns an immutable array.

…mutable arrays

The ZVAL_ARR macro always set the zval type_info to IS_ARRAY_EX, even if the
hash table is immutable. Since in preg_replace_callback_array() we can return
the passed array directly, and that passed array can be immutable, we need to
reset the type_flags to keep the VM from performing ref-counting on the array.

Fixes phpGH-10968
if (subject_ht) {
RETURN_ARR(subject_ht);
RETVAL_ARR(subject_ht);
if (GC_FLAGS(subject_ht) & GC_IMMUTABLE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (GC_FLAGS(subject_ht) & GC_IMMUTABLE) {
if (GC_FLAGS(subject_ht) & IS_ARRAY_IMMUTABLE) {

Maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I forgot we have an alias. Thanks!

@iluuu1994 iluuu1994 closed this in 66ce205 Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants