Skip to content

Commit 98976c9

Browse files
committed
random: Initialize the mode field when seeding in php_random_default_status() (php#13608)
This is not just an issue due to missing initialization since moving the state struct directly into the module globals. In earlier versions changing the mode to `MT_RAND_PHP` within a single request would also affect the mode for subsequent requests. Original commit message follows: This is a follow-up fix for phpGH-13579. The issue was detected in the nightly MSAN build. (cherry picked from commit bf0abd1)
1 parent 809446d commit 98976c9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ext/random/random.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ PHPAPI php_random_status *php_random_default_status(void)
334334
php_random_status *status = RANDOM_G(mt19937);
335335

336336
if (!RANDOM_G(mt19937_seeded)) {
337+
((php_random_status_state_mt19937 *)status->state)->mode = MT_RAND_MT19937;
337338
php_random_mt19937_seed_default(status->state);
338339
RANDOM_G(mt19937_seeded) = true;
339340
}

0 commit comments

Comments
 (0)