Skip to content

Commit c6eb5dc

Browse files
committed
Fix possible crash in case of exception
Fixes oss-fuzz #49068
1 parent f6aa7a4 commit c6eb5dc

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/reflection/php_reflection.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6972,6 +6972,9 @@ ZEND_METHOD(ReflectionEnumBackedCase, getBackingValue)
69726972

69736973
if (Z_TYPE(ref->value) == IS_CONSTANT_AST) {
69746974
zval_update_constant_ex(&ref->value, ref->ce);
6975+
if (EG(exception)) {
6976+
return;
6977+
}
69756978
}
69766979

69776980
ZEND_ASSERT(intern->ce->enum_backing_type != IS_UNDEF);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
ReflectionEnumBackedCase::getBackingValue() exception
3+
--FILE--
4+
<?php
5+
enum Inm:int {
6+
case Foo=y;
7+
}
8+
try {
9+
var_dump((new ReflectionEnumBackedCase(Inm::class,'Foo'))->getBackingValue());
10+
} catch (Error $e) {
11+
echo $e->getMessage() . "\n";
12+
}
13+
?>
14+
--EXPECT--
15+
Undefined constant "y"

0 commit comments

Comments
 (0)