Skip to content

Commit 65bbd92

Browse files
committed
Initialize retval on bitwise_not exception
1 parent ac99d5b commit 65bbd92

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Promoting float precision warning to exception in bitwise_not
3+
--FILE--
4+
<?php
5+
set_error_handler(function($_, $msg) {
6+
throw new Exception($msg);
7+
});
8+
try {
9+
var_dump(~INF);
10+
} catch (Exception $e) {
11+
echo $e->getMessage(), "\n";
12+
}
13+
?>
14+
--EXPECT--
15+
Implicit conversion from float INF to int loses precision

Zend/zend_operators.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,9 @@ ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1)
15001500
if (!zend_is_long_compatible(Z_DVAL_P(op1), lval)) {
15011501
zend_incompatible_double_to_long_error(Z_DVAL_P(op1));
15021502
if (EG(exception)) {
1503+
if (result != op1) {
1504+
ZVAL_UNDEF(result);
1505+
}
15031506
return FAILURE;
15041507
}
15051508
}

0 commit comments

Comments
 (0)