Skip to content

Commit

Permalink
Fix possible crash in case of exception
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #49068
  • Loading branch information
dstogov committed Jul 18, 2022
1 parent f6aa7a4 commit c6eb5dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/reflection/php_reflection.c
Expand Up @@ -6972,6 +6972,9 @@ ZEND_METHOD(ReflectionEnumBackedCase, getBackingValue)

if (Z_TYPE(ref->value) == IS_CONSTANT_AST) {
zval_update_constant_ex(&ref->value, ref->ce);
if (EG(exception)) {
return;
}
}

ZEND_ASSERT(intern->ce->enum_backing_type != IS_UNDEF);
Expand Down
@@ -0,0 +1,15 @@
--TEST--
ReflectionEnumBackedCase::getBackingValue() exception
--FILE--
<?php
enum Inm:int {
case Foo=y;
}
try {
var_dump((new ReflectionEnumBackedCase(Inm::class,'Foo'))->getBackingValue());
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Undefined constant "y"

0 comments on commit c6eb5dc

Please sign in to comment.