Skip to content

Commit 629965c

Browse files
committed
Handle promoted exception in int|string type
Fixes oss-fuzz #35790.
1 parent 9a42d2b commit 629965c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Promote deprecation warning for int|string type into exception
3+
--FILE--
4+
<?php
5+
6+
function test(int|string $arg) {}
7+
8+
set_error_handler(function($_, $msg) {
9+
throw new Exception($msg);
10+
});
11+
12+
try {
13+
test(0.5);
14+
} catch (Exception $e) {
15+
echo $e->getMessage(), "\n";
16+
}
17+
18+
?>
19+
--EXPECT--
20+
Implicit conversion from float 0.5 to int loses precision

Zend/zend_execute.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,8 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
726726
zval_ptr_dtor(arg);
727727
ZVAL_LONG(arg, lval);
728728
return 1;
729+
} else if (UNEXPECTED(EG(exception))) {
730+
return 0;
729731
}
730732
}
731733
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) {

0 commit comments

Comments
 (0)