1
0
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:
Saki Takamachi
2024-09-24 22:33:36 +09:00
committed by GitHub
parent 654b787ee1
commit c5b258fedc
3 changed files with 25 additions and 1 deletions

2
NEWS
View File

@@ -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)

View File

@@ -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;
}
}
}

View 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