Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ PHP NEWS
. Fixed use-after-free when a Fiber callable resolves to $this of the method
creating the Fiber ([A::class, 'm'] or "A::m") and that object dies before
the Fiber runs. (Edmond Dantes)
. Fixed object_properties_load() adding integer keys to property tables, which
made the properties unreadable and clone hit an assertion.
(Nicolas Grekas)

- CLI:
. Fixed built-in server rejecting long request paths, or paths received in
Expand Down
5 changes: 4 additions & 1 deletion Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,10 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
ZSTR_VAL(object->ce->name), h);
}

prop = zend_hash_index_update(zend_std_get_properties_ex(object), h, prop);
/* Property tables only have string keys */
zend_string *name = zend_long_to_str(h);
prop = zend_hash_update(zend_std_get_properties_ex(object), name, prop);
zend_string_release_ex(name, false);
zval_add_ref(prop);
}
} ZEND_HASH_FOREACH_END();
Expand Down
2 changes: 1 addition & 1 deletion ext/gmp/tests/gmp_dynamic_property.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Deprecated: Creation of dynamic property GMP::$1 is deprecated in %s on line %d

Deprecated: Creation of dynamic property GMP::$1 is deprecated in %s on line %d
object(GMP)#%d (%d) {
[1]=>
["1"]=>
int(123)
["num"]=>
string(1) "0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Integer keys in the properties that internal classes load when unserialized
--FILE--
<?php

#[AllowDynamicProperties]
class Storage extends SplObjectStorage {}

$storage = unserialize('O:7:"Storage":2:{i:0;a:0:{}i:1;a:1:{i:7;s:1:"y";}}');
var_dump($storage->{7});
var_dump(clone $storage);

?>
--EXPECT--
string(1) "y"
object(Storage)#2 (2) {
["7"]=>
string(1) "y"
["storage":"SplObjectStorage":private]=>
array(0) {
}
}
Loading