Skip to content

Commit bd84731

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix Randomizer::__serialize() wrt INDIRECTs
2 parents 27035eb + c5fa769 commit bd84731

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
. Fixed bug GH-20085 (Assertion failure when combining lazy object
1010
get_properties exception with foreach loop). (nielsdos)
1111

12+
- Random:
13+
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
14+
1215
09 Oct 2025, PHP 8.4.14
1316

1417
- Core:

ext/random/randomizer.c

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

518518
array_init(return_value);
519-
ZVAL_ARR(&t, zend_std_get_properties(&randomizer->std));
520-
Z_TRY_ADDREF(t);
519+
ZVAL_ARR(&t, zend_array_dup(zend_std_get_properties(&randomizer->std)));
521520
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &t);
522521
}
523522
/* }}} */
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)