mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.5'
* PHP-8.5: Fix hooked object properties overflow
This commit is contained in:
40
Zend/tests/property_hooks/gh20479.phpt
Normal file
40
Zend/tests/property_hooks/gh20479.phpt
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
--TEST--
|
||||||
|
GH-20479: Hooked object properties overflow
|
||||||
|
--CREDITS--
|
||||||
|
Viet Hoang Luu (@vi3tL0u1s)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
#[AllowDynamicProperties]
|
||||||
|
class Trigger {
|
||||||
|
public $a = 'x';
|
||||||
|
public $b = 'x';
|
||||||
|
public $c = 'x';
|
||||||
|
public $d = 'x';
|
||||||
|
public $e = 'x';
|
||||||
|
public $f = 'x';
|
||||||
|
public string $trigger {
|
||||||
|
get {
|
||||||
|
return 'trigger';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = new Trigger();
|
||||||
|
// Add 2 dynamic props
|
||||||
|
$obj->g = $obj->h = 'x';
|
||||||
|
var_export($obj);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
\Trigger::__set_state(array(
|
||||||
|
'a' => 'x',
|
||||||
|
'b' => 'x',
|
||||||
|
'c' => 'x',
|
||||||
|
'd' => 'x',
|
||||||
|
'e' => 'x',
|
||||||
|
'f' => 'x',
|
||||||
|
'trigger' => 'trigger',
|
||||||
|
'h' => 'x',
|
||||||
|
'g' => 'x',
|
||||||
|
))
|
||||||
@@ -121,7 +121,7 @@ skip_property:
|
|||||||
if (Z_TYPE_P(prop_value) == IS_INDIRECT) {
|
if (Z_TYPE_P(prop_value) == IS_INDIRECT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
zval *tmp = _zend_hash_append(properties, prop_name, prop_value);
|
zval *tmp = zend_hash_add_new(properties, prop_name, prop_value);
|
||||||
Z_TRY_ADDREF_P(tmp);
|
Z_TRY_ADDREF_P(tmp);
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user