Skip to content

Commit

Permalink
Handle promoted exception in int|string type
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #35790.
  • Loading branch information
nikic committed Jul 5, 2021
1 parent 9a42d2b commit 629965c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 629965c

Please sign in to comment.