Skip to content

Commit 09210e0

Browse files
committed
Fix phpGH-10571: Assertion `zval_get_type(&(*(zptr))) == 6 && "Concat should return string"' failed
1 parent 1fc2ddc commit 09210e0

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

Zend/tests/gh10571.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-10571: Assertion `zval_get_type(&(*(zptr))) == 6 && "Concat should return string"' failed
3+
--FILE--
4+
<?php
5+
class A
6+
{
7+
public string $prop = "";
8+
}
9+
10+
class B
11+
{
12+
public function __toString()
13+
{
14+
global $a;
15+
$a = "";
16+
return "";
17+
}
18+
}
19+
20+
$a = new A();
21+
$a->prop .= new B();
22+
var_dump($a);
23+
?>
24+
--EXPECT--
25+
string(0) ""

Zend/zend_vm_def.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,10 @@ ZEND_VM_C_LABEL(assign_op_object):
10591059
zval *orig_zptr = zptr;
10601060
zend_reference *ref;
10611061

1062+
if (OP1_TYPE == IS_CV) {
1063+
GC_ADDREF(zobj);
1064+
}
1065+
10621066
do {
10631067
if (UNEXPECTED(Z_ISREF_P(zptr))) {
10641068
ref = Z_REF_P(zptr);
@@ -1085,6 +1089,10 @@ ZEND_VM_C_LABEL(assign_op_object):
10851089
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
10861090
ZVAL_COPY(EX_VAR(opline->result.var), zptr);
10871091
}
1092+
1093+
if (OP1_TYPE == IS_CV) {
1094+
GC_DTOR(zobj);
1095+
}
10881096
}
10891097
} else {
10901098
zend_assign_op_overloaded_property(zobj, name, cache_slot, value OPLINE_CC EXECUTE_DATA_CC);

Zend/zend_vm_execute.h

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)