mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix exception in assert() callback with bail enabled
This commit is contained in:
commit
41958082bd
3 changed files with 43 additions and 0 deletions
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 (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();
|
zend_throw_unwind_exit();
|
||||||
RETURN_THROWS();
|
RETURN_THROWS();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue