mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix BC break of zend_throw_exception
This also fixes a SegFault Closes GH-5670
This commit is contained in:
parent
aa9b0ccda8
commit
cb2275866d
2 changed files with 18 additions and 2 deletions
|
@ -851,9 +851,11 @@ static zend_object *zend_throw_exception_zstr(zend_class_entry *exception_ce, ze
|
||||||
|
|
||||||
ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code) /* {{{ */
|
ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code) /* {{{ */
|
||||||
{
|
{
|
||||||
zend_string *msg_str = zend_string_init(message, strlen(message), 0);
|
zend_string *msg_str = message ? zend_string_init(message, strlen(message), 0) : NULL;
|
||||||
zend_object *ex = zend_throw_exception_zstr(exception_ce, msg_str, code);
|
zend_object *ex = zend_throw_exception_zstr(exception_ce, msg_str, code);
|
||||||
zend_string_release(msg_str);
|
if (msg_str) {
|
||||||
|
zend_string_release(msg_str);
|
||||||
|
}
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
14
tests/lang/zend_throw_exception_001.phpt
Normal file
14
tests/lang/zend_throw_exception_001.phpt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
--TEST--
|
||||||
|
zend_throw_exception with NULL message
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
assert_options(ASSERT_EXCEPTION, true);
|
||||||
|
try {
|
||||||
|
$assert = 'assert';
|
||||||
|
$assert(false);
|
||||||
|
} catch (AssertionError $assertionError) {
|
||||||
|
echo 'Done' . PHP_EOL;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
Done
|
Loading…
Add table
Add a link
Reference in a new issue