Skip to content

Commit 4acac9b

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix leak on assign concat of array and empty string
2 parents 2022f2e + 9560e3b commit 4acac9b

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+
Warning: 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
@@ -1861,6 +1861,9 @@ ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval
18611861
}
18621862
} else if (UNEXPECTED(Z_STRLEN_P(op2) == 0)) {
18631863
if (EXPECTED(result != op1)) {
1864+
if (result == orig_op1) {
1865+
i_zval_ptr_dtor(result);
1866+
}
18641867
ZVAL_COPY(result, op1);
18651868
}
18661869
} else {

0 commit comments

Comments
 (0)