diff --git a/ext/dom/tests/gh17201.phpt b/ext/dom/tests/gh17201.phpt new file mode 100644 index 0000000000000..a7d8ecd827db5 --- /dev/null +++ b/ext/dom/tests/gh17201.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-17201 (Dom\TokenList issues with interned string replace) +--EXTENSIONS-- +dom +--INI-- +opcache.protect_memory=1 +--FILE-- +'); +$element = $dom->documentElement; +$list = $element->classList; +$list->replace('AA', 'AB'); // Use interned string +foreach ($list as $entry) { + var_dump($entry); +} +?> +--EXPECT-- +string(2) "AB" +string(1) "B" +string(1) "C" diff --git a/ext/dom/token_list.c b/ext/dom/token_list.c index 15eaeb402017d..fe768e17b2e9c 100644 --- a/ext/dom/token_list.c +++ b/ext/dom/token_list.c @@ -583,7 +583,8 @@ PHP_METHOD(Dom_TokenList, replace) /* It already exists, remove token instead. */ zend_hash_del_bucket(token_set, bucket); } else { - Z_STR(bucket->val) = new_token; + /* Need to use ZVAL_STR instead of Z_STR to reset the type flags. */ + ZVAL_STR(&bucket->val, new_token); } /* 5. Run the update steps. */ diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 5d7949308a303..b919501c0dd25 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -239,10 +239,14 @@ static HashTable* spl_fixedarray_object_get_properties_for(zend_object *obj, zen zval *const elements = intern->array.elements; HashTable *ht = zend_new_array(size); - for (zend_long i = 0; i < size; i++) { - Z_TRY_ADDREF_P(&elements[i]); - zend_hash_next_index_insert(ht, &elements[i]); + /* The array elements are not *real properties*. */ + if (purpose != ZEND_PROP_PURPOSE_GET_OBJECT_VARS) { + for (zend_long i = 0; i < size; i++) { + Z_TRY_ADDREF_P(&elements[i]); + zend_hash_next_index_insert(ht, &elements[i]); + } } + if (source_properties && zend_hash_num_elements(source_properties) > 0) { zend_long nkey; zend_string *skey; diff --git a/ext/spl/tests/gh17198.phpt b/ext/spl/tests/gh17198.phpt new file mode 100644 index 0000000000000..8bc652d49ef4a --- /dev/null +++ b/ext/spl/tests/gh17198.phpt @@ -0,0 +1,17 @@ +--TEST-- +GH-17198 (SplFixedArray assertion failure with get_object_vars) +--FILE-- +{0} = []; +var_dump(get_object_vars($array)); +?> +--EXPECT-- +array(1) { + [0]=> + array(0) { + } +} diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c index d64703755cbe0..b329bdac728bb 100644 --- a/sapi/phpdbg/phpdbg_info.c +++ b/sapi/phpdbg/phpdbg_info.c @@ -374,7 +374,11 @@ PHPDBG_INFO(memory) /* {{{ */ static inline void phpdbg_print_class_name(zend_class_entry *ce) /* {{{ */ { const char *visibility = ce->type == ZEND_USER_CLASS ? "User" : "Internal"; - const char *type = (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" : (ce->ce_flags & ZEND_ACC_ABSTRACT) ? "Abstract Class" : "Class"; + const char *type = (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" + : (ce->ce_flags & ZEND_ACC_ABSTRACT) ? "Abstract Class" + : (ce->ce_flags & ZEND_ACC_ENUM) ? "Enum" + : (ce->ce_flags & ZEND_ACC_TRAIT) ? "Trait" + : "Class"; phpdbg_writeln("%s %s %.*s (%d)", visibility, type, (int) ZSTR_LEN(ce->name), ZSTR_VAL(ce->name), zend_hash_num_elements(&ce->function_table)); } /* }}} */