mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix exception in assert() callback with bail enabled
This commit is contained in:
4
NEWS
4
NEWS
@@ -65,6 +65,10 @@ PHP NEWS
|
||||
- SPL:
|
||||
. Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with
|
||||
bail enabled). (ilutov)
|
||||
|
||||
- XMLReader:
|
||||
. Fixed bug GH-16292 (Segmentation fault in ext/xmlreader/php_xmlreader.c).
|
||||
(nielsdos)
|
||||
|
||||
19
Zend/tests/gh16293_001.phpt
Normal file
19
Zend/tests/gh16293_001.phpt
Normal file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
GH-16293: Exception in assert() callback with bail enabled
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
assert_options(ASSERT_EXCEPTION, 0);
|
||||
assert_options(ASSERT_BAIL, 1);
|
||||
assert_options(ASSERT_CALLBACK, 'f1');
|
||||
assert(false);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: assert(): assert(false) failed in %s on line %d
|
||||
|
||||
Warning: Uncaught Error: Invalid callback f1, function "f1" not found or invalid function name in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): assert(false, 'assert(false)')
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
||||
19
Zend/tests/gh16293_002.phpt
Normal file
19
Zend/tests/gh16293_002.phpt
Normal file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
GH-16293: Exception in assert() callback with bail enabled
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
assert_options(ASSERT_EXCEPTION, 0);
|
||||
assert_options(ASSERT_BAIL, 1);
|
||||
assert_options(ASSERT_CALLBACK, function () {
|
||||
throw new Exception('Boo');
|
||||
});
|
||||
assert(false);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: assert(): assert(false) failed in %s on line %d
|
||||
|
||||
Warning: Uncaught Exception: Boo in %s:%d
|
||||
Stack trace:
|
||||
%a
|
||||
@@ -238,6 +238,11 @@ PHP_FUNCTION(assert)
|
||||
}
|
||||
|
||||
if (ASSERTG(bail)) {
|
||||
if (EG(exception)) {
|
||||
/* The callback might have thrown. Use E_WARNING to print the
|
||||
* exception so we can avoid bailout and use unwind_exit. */
|
||||
zend_exception_error(EG(exception), E_WARNING);
|
||||
}
|
||||
zend_throw_unwind_exit();
|
||||
RETURN_THROWS();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user