From 5111f3ebd6051c5e133cd6271dcc0be8280a81b8 Mon Sep 17 00:00:00 2001 From: Rowan Tommins Date: Tue, 31 May 2022 21:58:46 +0100 Subject: [PATCH] Avoid accessing undefined variables in run-tests.php The $php_cgi and $phpdbg cases here are definitely real bugs, and caused the script to bail out under certain ini settings. The other paths may actually be unreachable in practice, but were highlighted by PhpStorm. --- run-tests.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/run-tests.php b/run-tests.php index 0a091d5d8af9..b28458845ff8 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1802,13 +1802,8 @@ function run_test(string $php, $file, array $env): string $org_file = $file; $orig_php = $php; - if (isset($env['TEST_PHP_CGI_EXECUTABLE'])) { - $php_cgi = $env['TEST_PHP_CGI_EXECUTABLE']; - } - - if (isset($env['TEST_PHPDBG_EXECUTABLE'])) { - $phpdbg = $env['TEST_PHPDBG_EXECUTABLE']; - } + $php_cgi = $env['TEST_PHP_CGI_EXECUTABLE'] ?? null; + $phpdbg = $env['TEST_PHPDBG_EXECUTABLE'] ?? null; if (is_array($file)) { $file = $file[0]; @@ -2489,6 +2484,8 @@ function run_test(string $php, $file, array $env): string } } + $wanted_headers = null; + $output_headers = null; $failed_headers = false; if ($test->hasSection('EXPECTHEADERS')) { @@ -2647,6 +2644,8 @@ function run_test(string $php, $file, array $env): string } } + $restype = []; + if ($leaked) { $restype[] = $test->hasSection('XLEAK') ? 'XLEAK' : 'LEAK';