Skip to content

Commit cd2afd9

Browse files
committed
Fix leak on assign concat of array and empty string
1 parent 488e53c commit cd2afd9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Assign concat of array and empty string
3+
--FILE--
4+
<?php
5+
6+
$a = [0];
7+
$a .= '';
8+
var_dump($a);
9+
10+
?>
11+
--EXPECTF--
12+
Notice: Array to string conversion in %s on line %d
13+
string(5) "Array"

Zend/zend_operators.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,9 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /
18361836
}
18371837
} else if (UNEXPECTED(Z_STRLEN_P(op2) == 0)) {
18381838
if (EXPECTED(result != op1)) {
1839+
if (result == orig_op1) {
1840+
i_zval_ptr_dtor(result ZEND_FILE_LINE_CC);
1841+
}
18391842
ZVAL_COPY(result, op1);
18401843
}
18411844
} else {

0 commit comments

Comments
 (0)