mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
random: Fix check before closing random_fd
(#10247)
If, for whatever reason, the random_fd has been assigned file descriptor `0` it previously failed to close during module shutdown, thus leaking the descriptor.
This commit is contained in:
parent
df96346f9c
commit
32f503e4e3
3
NEWS
3
NEWS
@ -30,6 +30,9 @@ PHP NEWS
|
||||
- Posix:
|
||||
. Fix memory leak in posix_ttyname() (girgias)
|
||||
|
||||
- Random:
|
||||
. Fixed bug GH-10247 (Theoretical file descriptor leak for /dev/urandom). (timwolla)
|
||||
|
||||
- Standard:
|
||||
. Fix GH-10187 (Segfault in stripslashes() with arm64). (nielsdos)
|
||||
|
||||
|
@ -828,7 +828,7 @@ static PHP_GINIT_FUNCTION(random)
|
||||
/* {{{ PHP_GSHUTDOWN_FUNCTION */
|
||||
static PHP_GSHUTDOWN_FUNCTION(random)
|
||||
{
|
||||
if (random_globals->random_fd > 0) {
|
||||
if (random_globals->random_fd >= 0) {
|
||||
close(random_globals->random_fd);
|
||||
random_globals->random_fd = -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user