Handle promoted exception in int|string type

Fixes oss-fuzz #35790.
This commit is contained in:
Nikita Popov 2021-07-05 10:47:42 +02:00
parent 9a42d2b87b
commit 629965c80f
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,20 @@
--TEST--
Promote deprecation warning for int|string type into exception
--FILE--
<?php
function test(int|string $arg) {}
set_error_handler(function($_, $msg) {
throw new Exception($msg);
});
try {
test(0.5);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Implicit conversion from float 0.5 to int loses precision

View File

@ -726,6 +726,8 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
zval_ptr_dtor(arg);
ZVAL_LONG(arg, lval);
return 1;
} else if (UNEXPECTED(EG(exception))) {
return 0;
}
}
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) {