mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-15968: Avoid converting objects to strings in operator calculations. (#16021)
This commit is contained in:
2
NEWS
2
NEWS
@@ -6,6 +6,8 @@ PHP NEWS
|
||||
. bcpow() performance improvement. (Jorg Sowa)
|
||||
. ext/bcmath: Check for scale overflow. (SakiTakamachi)
|
||||
. [RFC] ext/bcmath: Added bcdivmod. (SakiTakamachi)
|
||||
. Fix GH-15968 (Avoid converting objects to strings in operator calculations).
|
||||
(SakiTakamachi)
|
||||
|
||||
- Curl:
|
||||
. Added CURLOPT_DEBUGFUNCTION as a Curl option. (Ayesh Karunaratne)
|
||||
|
||||
@@ -1178,7 +1178,7 @@ static zend_result bcmath_number_parse_num(zval *zv, zend_object **obj, zend_str
|
||||
return FAILURE;
|
||||
|
||||
default:
|
||||
return zend_parse_arg_str_or_long_slow(zv, str, lval, 1 /* dummy */) ? SUCCESS : FAILURE;
|
||||
return zend_parse_arg_long_slow(zv, lval, 1 /* dummy */) ? SUCCESS : FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
ext/bcmath/tests/gh15968.phpt
Normal file
22
ext/bcmath/tests/gh15968.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-15968 BCMath\Number operators may typecast operand
|
||||
--EXTENSIONS--
|
||||
bcmath
|
||||
--FILE--
|
||||
<?php
|
||||
class MyString {
|
||||
function __toString() {
|
||||
return "2";
|
||||
}
|
||||
}
|
||||
|
||||
$a = new BCMath\Number("1");
|
||||
$b = new MyString();
|
||||
try {
|
||||
var_dump($a + $b);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Unsupported operand types: BcMath\Number + MyString
|
||||
Reference in New Issue
Block a user