Skip to content

Commit 1f6b842

Browse files
committed
Fixed bug #76536 (PHP crashes with core dump when throwing exception in error handler). (Laruence)
1 parent d1b1866 commit 1f6b842

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ PHP NEWS
1818
- phpdbg:
1919
. Fix arginfo wrt. optional/required parameters. (cmb)
2020

21+
- Reflection:
22+
. Fixed bug #76536 (PHP crashes with core dump when throwing exception in
23+
error handler). (Laruence)
24+
2125
- Standard:
2226
. Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys).
2327
(Laruence)

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4617,7 +4617,7 @@ ZEND_METHOD(reflection_class, getConstants)
46174617
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) {
46184618
if (UNEXPECTED(zval_update_constant_ex(&c->value, ce) != SUCCESS)) {
46194619
zend_array_destroy(Z_ARRVAL_P(return_value));
4620-
return;
4620+
RETURN_NULL();
46214621
}
46224622
val = zend_hash_add_new(Z_ARRVAL_P(return_value), key, &c->value);
46234623
Z_TRY_ADDREF_P(val);

ext/reflection/tests/bug76536.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #76536 (PHP crashes with core dump when throwing exception in error handler)
3+
--FILE--
4+
<?php
5+
class SomeConstants {const SOME_CONSTANT = SOME_NONSENSE;}
6+
7+
function handleError() {throw new ErrorException();}
8+
9+
set_error_handler('handleError');
10+
set_exception_handler('handleError');
11+
12+
$r = new \ReflectionClass(SomeConstants::class);
13+
$r->getConstants();
14+
?>
15+
--EXPECTF--
16+
Fatal error: Uncaught ErrorException in %sbug76536.php:%d
17+
Stack trace:
18+
#0 [internal function]: handleError(Object(ErrorException))
19+
#1 {main}
20+
thrown in %sbug76536.php on line %d

0 commit comments

Comments
 (0)