Fix failed assertion with throwing __toString in binary const expr

Solve this with the same pattern as ZEND_AST_GREATER[_EQUAL].

Fixes OSS-Fuzz #434346548
Closes GH-19291
This commit is contained in:
Ilija Tovilo 2025-07-29 22:34:47 +02:00
parent be9f1d3d56
commit 80022c035b
No known key found for this signature in database
GPG key ID: 115CEA7A713E12E9
3 changed files with 26 additions and 1 deletions

2
NEWS
View file

@ -7,6 +7,8 @@ PHP NEWS
(psumbera)
. Fixed bug GH-18581 (Coerce numeric string keys from iterators when argument
unpacking). (ilutov)
. Fixed OSS-Fuzz #434346548 (Failed assertion with throwing __toString in
binary const expr). (ilutov)
- FTP:
. Fix theoretical issues with hrtime() not being available. (nielsdos)

View file

@ -0,0 +1,22 @@
--TEST--
OSS-Fuzz #434346548: Failed assertion with throwing __toString in binary const expr
--FILE--
<?php
class Foo {
function __toString() {}
}
function test($y = new Foo() < "") {
var_dump();
}
try {
test();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Foo::__toString(): Return value must be of type string, none returned

View file

@ -548,9 +548,10 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
ret = FAILURE;
} else {
binary_op_type op = get_binary_op(ast->attr);
ret = op(result, &op1, &op2);
op(result, &op1, &op2);
zval_ptr_dtor_nogc(&op1);
zval_ptr_dtor_nogc(&op2);
ret = EG(exception) ? FAILURE : SUCCESS;
}
break;
case ZEND_AST_GREATER: