mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Use zend_throw_unwind_exit() for assert.bail (#6826)
We can use unwind_exit instead of the evil zend_bailout without breaking the original behavior in this way because the original zend_bailout will longjmp out of the executor, so the exception will never be caught and it always triggers the E_ERROR here.
This commit is contained in:
parent
b7a298b20c
commit
d5456baf52
@ -7,7 +7,11 @@ assert.exception=1
|
||||
<?php
|
||||
|
||||
define ("XXXXX", 1);
|
||||
assert(false);
|
||||
try {
|
||||
assert(false);
|
||||
} catch (AssertionError $error) {
|
||||
echo "Caught\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
|
@ -186,15 +186,20 @@ PHP_FUNCTION(assert)
|
||||
|
||||
if (ASSERTG(exception)) {
|
||||
zend_throw_exception(assertion_error_ce, description_str ? ZSTR_VAL(description_str) : NULL, E_ERROR);
|
||||
if (ASSERTG(bail)) {
|
||||
/* When bail is turned on, the exception will not be caught. */
|
||||
zend_exception_error(EG(exception), E_ERROR);
|
||||
}
|
||||
} else if (ASSERTG(warning)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s failed", description_str ? ZSTR_VAL(description_str) : "Assertion failed");
|
||||
}
|
||||
|
||||
if (ASSERTG(bail)) {
|
||||
zend_bailout();
|
||||
zend_throw_unwind_exit();
|
||||
RETURN_THROWS();
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user