Skip to content

Commit b59479c

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix Randomizer::__serialize() wrt INDIRECTs
2 parents aaed3cc + d0615d7 commit b59479c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ext/random/randomizer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,7 @@ PHP_METHOD(Random_Randomizer, __serialize)
509509
ZEND_PARSE_PARAMETERS_NONE();
510510

511511
array_init(return_value);
512-
ZVAL_ARR(&t, zend_std_get_properties(&randomizer->std));
513-
Z_TRY_ADDREF(t);
512+
ZVAL_ARR(&t, zend_array_dup(zend_std_get_properties(&randomizer->std)));
514513
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &t);
515514
}
516515
/* }}} */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Random: Engine: __serialize() must not expose INDIRECTs
3+
--FILE--
4+
<?php
5+
6+
$randomizer = new Random\Randomizer(null);
7+
var_dump($randomizer->__serialize());
8+
9+
?>
10+
--EXPECT--
11+
array(1) {
12+
[0]=>
13+
array(1) {
14+
["engine"]=>
15+
object(Random\Engine\Secure)#2 (0) {
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)