[php-src] master: Merge branch 'PHP-8.2' into PHP-8.3

From: Date: Mon, 15 Apr 2024 17:40:29 +0000
Subject: [php-src] master: Merge branch 'PHP-8.2' into PHP-8.3
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-128127@lists.php.net to get a copy of this message
Author: Niels Dossche (nielsdos) Date: 2024-04-15T19:39:59+02:00 Commit: https://github.com/php/php-src/commit/550e0ceb7919bd6a1dc7bcacf437577e353c466d Raw diff: https://github.com/php/php-src/commit/550e0ceb7919bd6a1dc7bcacf437577e353c466d.diff Merge branch 'PHP-8.2' into PHP-8.3 * PHP-8.2: Fix GH-13931: Applying zero offset to null pointer in Zend/zend_opcode.c Changed paths: A Zend/tests/gh13931.phpt A sapi/phpdbg/tests/gh13931.phpt M NEWS M main/main.c Diff: diff --git a/NEWS b/NEWS index f44490fadbb8f..2027ebcc5d9d2 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS (Fabrice Fontaine) . Fixed bug GH-13772 (Invalid execute_data->opline pointers in observer fcall handlers when JIT is enabled). (Bob) + . Fixed bug GH-13931 (Applying zero offset to null pointer in + Zend/zend_opcode.c). (nielsdos) - Fibers: . Fixed bug GH-13903 (ASAN false positive underflow when executing copy()). diff --git a/Zend/tests/gh13931.phpt b/Zend/tests/gh13931.phpt new file mode 100644 index 0000000000000..5f2873b449f94 --- /dev/null +++ b/Zend/tests/gh13931.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-13931 (Applying zero offset to null pointer in Zend/zend_opcode.c) +--FILE-- +<?php + +register_shutdown_function(function() { + var_dump(eval("return 1+3;")); +}); + +eval(<<<EVAL +function foo () { + try { + break; + } finally { + } +} +foo(); +EVAL); + +?> +--EXPECTF-- +Fatal error: 'break' not in the 'loop' or 'switch' context in %s on line %d +int(4) diff --git a/main/main.c b/main/main.c index fb68bd1b3dd39..3c9c55129e971 100644 --- a/main/main.c +++ b/main/main.c @@ -1416,6 +1416,14 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c /* restore memory limit */ zend_set_memory_limit(PG(memory_limit)); zend_objects_store_mark_destructed(&EG(objects_store)); + if (CG(in_compilation) && (type == E_COMPILE_ERROR || type == E_PARSE)) { + /* We bailout during compilation which may for example leave stale entries in CG(loop_var_stack). + * If code is compiled during shutdown, we need to make sure the compiler is reset to a clean state, + * otherwise this will lead to incorrect compilation during shutdown. + * We don't do a full re-initialization via init_compiler() because that will also reset streams and resources. */ + shutdown_compiler(); + zend_init_compiler_data_structures(); + } zend_bailout(); return; } diff --git a/sapi/phpdbg/tests/gh13931.phpt b/sapi/phpdbg/tests/gh13931.phpt new file mode 100644 index 0000000000000..25520435feb9b --- /dev/null +++ b/sapi/phpdbg/tests/gh13931.phpt @@ -0,0 +1,21 @@ +--TEST-- +Applying zero offset to null pointer in Zend/zend_opcode.c +--FILE-- +<?php +function foo () { + try { + break; + } finally { + } +} +foo(); +?> +--PHPDBG-- +ev 1 + 3 +ev 2 ** 3 +q +--EXPECTF-- +Fatal error: 'break' not in the 'loop' or 'switch' context in %s on line %d +prompt> 4 +prompt> 8 +prompt>

« previous php.cvs (#128127) next »